@pipedream/dropbox 0.3.19 → 0.4.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.
@@ -2,16 +2,16 @@ import dropbox from "../../dropbox.app.mjs";
2
2
 
3
3
  export default {
4
4
  name: "Create a Text File",
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)",
5
+ description: "Creates a brand new text file from plain text content you specify. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
6
6
  key: "dropbox-create-a-text-file",
7
- version: "0.0.9",
7
+ version: "0.0.10",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
11
11
  name: {
12
12
  type: "string",
13
- label: "File name",
14
- description: "Your new file name.",
13
+ label: "File Name",
14
+ description: "Your new file name. Example: `textfile.txt`",
15
15
  },
16
16
  path: {
17
17
  propDefinition: [
@@ -36,9 +36,13 @@ export default {
36
36
  path,
37
37
  } = this;
38
38
 
39
+ const filename = name.includes(".txt")
40
+ ? name
41
+ : `${name}.txt`;
42
+
39
43
  const res = await this.dropbox.uploadFile({
40
44
  contents: Buffer.from(content),
41
- path: this.dropbox.getNormalizedPath(path, true) + name,
45
+ path: this.dropbox.getNormalizedPath(path, true) + filename,
42
46
  autorename: true,
43
47
  });
44
48
 
@@ -2,15 +2,15 @@ import dropbox from "../../dropbox.app.mjs";
2
2
 
3
3
  export default {
4
4
  name: "Create folder",
5
- description: "Create a folder. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCreateFolderV2__anchor)",
5
+ description: "Create a Folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCreateFolderV2__anchor)",
6
6
  key: "dropbox-create-folder",
7
- version: "0.0.9",
7
+ version: "0.0.10",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
11
11
  name: {
12
12
  type: "string",
13
- label: "Folder name",
13
+ label: "Folder Name",
14
14
  description: "Your new folder name.",
15
15
  },
16
16
  path: {
@@ -2,15 +2,15 @@ import dropbox from "../../dropbox.app.mjs";
2
2
 
3
3
  export default {
4
4
  name: "Create or Append to a Text File",
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)",
5
+ description: "Adds a new line to an existing text file, or creates a file if it doesn't exist. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
6
6
  key: "dropbox-create-or-append-to-a-text-file",
7
- version: "0.0.9",
7
+ version: "0.0.10",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
11
11
  name: {
12
12
  type: "string",
13
- label: "File name",
13
+ label: "File Name",
14
14
  description: "Your new file name",
15
15
  },
16
16
  path: {
@@ -0,0 +1,10 @@
1
+ import dropbox from "../../dropbox.app.mjs";
2
+
3
+ export default {
4
+ props: {
5
+ dropbox: {
6
+ ...dropbox,
7
+ reloadProps: true,
8
+ },
9
+ },
10
+ };
@@ -1,17 +1,23 @@
1
- import dropbox from "../../dropbox.app.mjs";
1
+ import common from "./common.mjs";
2
2
  import consts from "../../common/consts.mjs";
3
3
 
4
4
  export default {
5
5
  name: "Create/Update a Share Link",
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)",
6
+ description: "Creates or updates a public share link to the file or folder (It allows you to share the file or folder with anyone). [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#sharingCreateSharedLinkWithSettings__anchor)",
7
7
  key: "dropbox-create-update-share-link",
8
- version: "0.0.9",
8
+ version: "0.0.10",
9
9
  type: "action",
10
10
  props: {
11
- dropbox,
11
+ ...common.props,
12
+ alert: {
13
+ type: "alert",
14
+ alertType: "warning",
15
+ content: `Dropbox Free and Basic users are able to create a publicly-available share link which allows downloads.
16
+ \nIn order to utilize advanced link sharing functionality, you must be on a Dropbox Essentials plan or higher. See the Dropbox pricing [page](https://www.dropbox.com/plans?trigger=nr#:~:text=Collaborative%20sharing) for more details.`,
17
+ },
12
18
  path: {
13
19
  propDefinition: [
14
- dropbox,
20
+ common.props.dropbox,
15
21
  "path",
16
22
  () => ({
17
23
  initialOptions: [],
@@ -23,42 +29,52 @@ export default {
23
29
  ],
24
30
  description: "Type the file or folder name to search for it in the user's Dropbox.",
25
31
  },
26
- requirePassword: {
27
- type: "boolean",
28
- label: "Require password",
29
- description: "Boolean flag to enable or disable password protection.",
30
- default: false,
31
- },
32
- linkPassword: {
33
- type: "string",
34
- label: "Link password",
35
- description: "If `require_password` is `true`, this is needed to specify the password to access the link.",
36
- optional: true,
37
- },
38
- allowDownload: {
39
- type: "boolean",
40
- label: "Allow downloads",
41
- description: "Boolean flag to allow or not allow capabilities for shared links.",
42
- },
43
- expires: {
44
- type: "string",
45
- label: "Expires",
46
- description: "Expiration time of the shared link. By default the link never expires. Make sure to use a valid [timestamp](https://dropbox.github.io/dropbox-sdk-js/global.html#Timestamp) value.",
47
- optional: true,
48
- },
49
- audience: {
50
- type: "string",
51
- label: "Audience",
52
- description: "The new audience who can benefit from the access level specified by the link's access level specified in the `link_access_level` field of `LinkPermissions`. This is used in conjunction with team policies and shared folder policies to determine the final effective audience type in the `effective_audience` field of `LinkPermissions.",
53
- optional: true,
54
- options: consts.CREATE_SHARED_LINK_AUDIENCE_OPTIONS,
55
- },
56
- access: {
57
- type: "string",
58
- label: "Access",
59
- description: "Requested access level you want the audience to gain from this link. Note, modifying access level for an existing link is not supported.",
60
- optional: true,
61
- options: consts.CREATE_SHARED_LINK_ACCESS_OPTIONS,
32
+ },
33
+ async additionalProps() {
34
+ const props = {};
35
+
36
+ const accountType = await this.getCurrentAccount();
37
+ if (accountType !== "basic") {
38
+ props.requirePassword = {
39
+ type: "boolean",
40
+ label: "Require Password",
41
+ description: "Boolean flag to enable or disable password protection.",
42
+ default: false,
43
+ reloadProps: true,
44
+ };
45
+ props.linkPassword = {
46
+ type: "string",
47
+ label: "Link Password",
48
+ description: "If `require_password` is `true`, this is needed to specify the password to access the link.",
49
+ hidden: !this.requirePassword,
50
+ };
51
+ props.allowDownload = {
52
+ type: "boolean",
53
+ label: "Allow Downloads",
54
+ description: "Boolean flag to allow or not allow capabilities for shared links.",
55
+ };
56
+ props.expires = {
57
+ type: "string",
58
+ label: "Expires",
59
+ description: "Expiration time of the shared link. By default the link never expires. Make sure to use a valid [timestamp](https://dropbox.github.io/dropbox-sdk-js/global.html#Timestamp) value. Example: `2024-07-18T20:00:00Z`",
60
+ optional: true,
61
+ };
62
+ props.access = {
63
+ type: "string",
64
+ label: "Access",
65
+ description: "Requested access level you want the audience to gain from this link. Note, modifying access level for an existing link is not supported.",
66
+ optional: true,
67
+ options: consts.CREATE_SHARED_LINK_ACCESS_OPTIONS,
68
+ };
69
+ }
70
+
71
+ return props;
72
+ },
73
+ methods: {
74
+ async getCurrentAccount() {
75
+ const dpx = await this.dropbox.sdk();
76
+ const { result: { account_type: accountType } } = await dpx.usersGetCurrentAccount();
77
+ return accountType[".tag"];
62
78
  },
63
79
  },
64
80
  async run({ $ }) {
@@ -67,29 +83,31 @@ export default {
67
83
  requirePassword,
68
84
  linkPassword,
69
85
  expires,
70
- audience,
71
86
  access,
72
- requestedVisibility,
73
- allowDownload,
74
- removeExpiration,
75
87
  } = this;
76
88
 
89
+ const accountType = await this.getCurrentAccount();
90
+ const allowDownload = accountType === "basic"
91
+ ? true
92
+ : this.allowDownload;
93
+
77
94
  if (requirePassword && !linkPassword) {
78
95
  throw new Error("Since the password is required, please add a linkPassword");
79
96
  }
80
97
 
98
+ if (expires && Date.parse(expires) < Date.now()) {
99
+ throw new Error("Expire date must be later than the current datetime");
100
+ }
101
+
81
102
  const res = await this.dropbox.createSharedLink({
82
103
  path: this.dropbox.getPath(path),
83
104
  settings: {
84
105
  require_password: requirePassword,
85
106
  link_password: linkPassword,
86
107
  expires,
87
- audience,
88
108
  access,
89
- requested_visibility: requestedVisibility,
90
109
  allow_download: allowDownload,
91
110
  },
92
- remove_expiration: removeExpiration,
93
111
  });
94
112
  $.export("$summary", `Shared link for "${path?.label || path}" successfully created`);
95
113
  return res;
@@ -2,9 +2,9 @@ import dropbox from "../../dropbox.app.mjs";
2
2
 
3
3
  export default {
4
4
  name: "Delete a File/Folder",
5
- description: "Permanently removes a file/folder from the server. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDeleteV2__anchor)",
5
+ description: "Permanently removes a file/folder from the server. [See documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDeleteV2__anchor)",
6
6
  key: "dropbox-delete-file-folder",
7
- version: "0.0.9",
7
+ version: "0.0.10",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -6,7 +6,7 @@ export default {
6
6
  name: "Download File to TMP",
7
7
  description: "Download a specific file to the temporary directory. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDownload__anchor).",
8
8
  key: "dropbox-download-file-to-tmp",
9
- version: "0.0.5",
9
+ version: "0.0.6",
10
10
  type: "action",
11
11
  props: {
12
12
  dropbox,
@@ -21,7 +21,7 @@ export default {
21
21
  },
22
22
  name: {
23
23
  type: "string",
24
- label: "File name",
24
+ label: "File Name",
25
25
  description: "The new name of the file to be saved, including it's extension. e.g: `myFile.csv`",
26
26
  optional: true,
27
27
  },
@@ -35,16 +35,18 @@ export default {
35
35
  path, cleanup,
36
36
  } = await file();
37
37
 
38
+ const extension = result.name.split(".").pop();
39
+
38
40
  const tmpPath = this.name
39
41
  ? `/tmp/${this.name}`
40
- : path;
42
+ : `${path}.${extension}`;
41
43
 
42
44
  await fs.promises.appendFile(tmpPath, Buffer.from(result.fileBinary));
43
45
  await cleanup();
44
46
 
45
47
  delete result.fileBinary;
46
48
 
47
- $.export("$summary", `File successfully saved in "/tmp/${this.name}"`);
49
+ $.export("$summary", `File successfully saved in "${tmpPath}"`);
48
50
 
49
51
  return {
50
52
  tmpPath,
@@ -2,9 +2,9 @@ import dropbox from "../../dropbox.app.mjs";
2
2
 
3
3
  export default {
4
4
  name: "List All Files/Subfolders in a Folder",
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)",
5
+ description: "Retrieves a list of files or subfolders in a specified folder [See the documentation](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.9",
7
+ version: "0.0.10",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -13,6 +13,7 @@ export default {
13
13
  dropbox,
14
14
  "path",
15
15
  () => ({
16
+ initialOptions: [],
16
17
  filter: ({ metadata: { metadata: { [".tag"]: type } } }) => type === "folder",
17
18
  }),
18
19
  ],
@@ -26,7 +27,7 @@ export default {
26
27
  },
27
28
  includeDeleted: {
28
29
  type: "boolean",
29
- label: "Include deleted",
30
+ label: "Include Deleted",
30
31
  description: "If `true`, the results will include files and folders that used to exist but were deleted.",
31
32
  default: false,
32
33
  },
@@ -3,9 +3,9 @@ import dropbox from "../../dropbox.app.mjs";
3
3
 
4
4
  export default {
5
5
  name: "List File Revisions",
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)",
6
+ description: "Retrieves a list of file revisions needed to recover previous content. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListRevisions__anchor)",
7
7
  key: "dropbox-list-file-revisions",
8
- version: "0.0.9",
8
+ version: "0.0.10",
9
9
  type: "action",
10
10
  props: {
11
11
  dropbox,
@@ -21,7 +21,7 @@ export default {
21
21
  mode: {
22
22
  type: "string",
23
23
  label: "Mode",
24
- description: "Determines the behavior of the API in listing the revisions for a given file path or id.",
24
+ description: "Determines the behavior of the API in listing the revisions for a given file path or id. In `path` (default) mode, all revisions at the same file path as the latest file entry are returned. If revisions with the same file id are desired, then mode must be set to `id`.",
25
25
  optional: true,
26
26
  options: consts.LIST_FILE_REVISIONS_OPTIONS,
27
27
  },
@@ -2,9 +2,9 @@ import dropbox from "../../dropbox.app.mjs";
2
2
 
3
3
  export default {
4
4
  name: "Move a File/Folder",
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)",
5
+ description: "Moves a file or folder to a different location in the user's Dropbox [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesMoveV2__anchor)",
6
6
  key: "dropbox-move-file-folder",
7
- version: "0.0.10",
7
+ version: "0.0.11",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -20,16 +20,19 @@ export default {
20
20
  ].includes(type),
21
21
  }),
22
22
  ],
23
- label: "Path from",
23
+ label: "Path From",
24
24
  description: "Type the file or folder name to search for it in the user's Dropbox.",
25
25
  },
26
26
  pathTo: {
27
27
  propDefinition: [
28
28
  dropbox,
29
29
  "path",
30
+ () => ({
31
+ filter: ({ metadata: { metadata: { [".tag"]: type } } }) => type === "folder",
32
+ }),
30
33
  ],
31
- label: "Path to",
32
- description: "Type the folder name to search for it in the user's Dropbox. If not filled, it will be moved in the root folder.",
34
+ label: "Path To",
35
+ description: "Type the folder name to search for it in the user's Dropbox.",
33
36
  },
34
37
  autorename: {
35
38
  type: "boolean",
@@ -39,7 +42,7 @@ export default {
39
42
  },
40
43
  allowOwnershipTransfer: {
41
44
  type: "boolean",
42
- label: "Allow ownership transfer",
45
+ label: "Allow Ownership Transfer",
43
46
  description: "Allow moves by owner even if it would result in an ownership transfer for the content being moved. This does not apply to copies.",
44
47
  optional: true,
45
48
  },
@@ -2,9 +2,9 @@ import dropbox from "../../dropbox.app.mjs";
2
2
 
3
3
  export default {
4
4
  name: "Rename a File/Folder",
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)",
5
+ description: "Renames a file or folder in the user's Dropbox [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesMoveV2__anchor)",
6
6
  key: "dropbox-rename-file-folder",
7
- version: "0.0.9",
7
+ version: "0.0.10",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -2,9 +2,9 @@ import dropbox from "../../dropbox.app.mjs";
2
2
 
3
3
  export default {
4
4
  name: "Restore a File",
5
- description: "Restores a previous file version. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesRestore__anchor)",
5
+ description: "Restores a previous file version. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesRestore__anchor)",
6
6
  key: "dropbox-restore-a-file",
7
- version: "0.0.9",
7
+ version: "0.0.10",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -14,11 +14,6 @@ export default {
14
14
  "path",
15
15
  () => ({
16
16
  initialOptions: [],
17
- params: {
18
- options: {
19
- file_status: "deleted",
20
- },
21
- },
22
17
  }),
23
18
  ],
24
19
  description: "Type the file name to search for it in the user's Dropbox.",
@@ -4,9 +4,9 @@ import consts from "../../common/consts.mjs";
4
4
 
5
5
  export default {
6
6
  name: "Search files and folders",
7
- description: "Searches for files and folders by name. [See the docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesSearchV2__anchor)",
7
+ description: "Searches for files and folders by name. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesSearchV2__anchor)",
8
8
  key: "dropbox-search-files-folders",
9
- version: "0.0.9",
9
+ version: "0.0.10",
10
10
  type: "action",
11
11
  props: {
12
12
  dropbox,
@@ -28,40 +28,40 @@ export default {
28
28
  },
29
29
  orderBy: {
30
30
  type: "string",
31
- label: "Order by",
31
+ label: "Order By",
32
32
  description: "By default, results are sorted by relevance.",
33
33
  optional: true,
34
34
  options: consts.SEARCH_FILE_FOLDER_ORDER_BY_OPTIONS,
35
35
  },
36
36
  fileStatus: {
37
37
  type: "string",
38
- label: "File status",
38
+ label: "File Status",
39
39
  description: "Restricts search to the given file status.",
40
40
  optional: true,
41
41
  options: consts.SEARCH_FILE_FOLDER_STATUS_OPTIONS,
42
42
  },
43
43
  filenameOnly: {
44
44
  type: "boolean",
45
- label: "Filename only",
45
+ label: "Filename Only",
46
46
  description: "Restricts search to only match on filenames.",
47
47
  optional: true,
48
48
  },
49
49
  fileCategories: {
50
50
  type: "string[]",
51
- label: "File categories",
51
+ label: "File Categories",
52
52
  description: "Restricts search to only the file categories specified. Only supported for active file search.",
53
53
  optional: true,
54
54
  options: consts.FILES_CATEGORIES_OPTIONS,
55
55
  },
56
56
  fileExtensions: {
57
57
  type: "string[]",
58
- label: "File extensions",
58
+ label: "File Extensions",
59
59
  description: "Restricts search to only the extensions specified. Only supported for active file search.",
60
60
  optional: true,
61
61
  },
62
62
  includeHighlights: {
63
63
  type: "boolean",
64
- label: "Include highlights",
64
+ label: "Include Highlights",
65
65
  description: "Whether to include highlight span from file title.",
66
66
  optional: true,
67
67
  },
@@ -2,12 +2,13 @@ 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";
5
+ import { ConfigurationError } from "@pipedream/platform";
5
6
 
6
7
  export default {
7
8
  name: "Upload a File",
8
- description: "Uploads a file to a selected folder. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
9
+ description: "Uploads a file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
9
10
  key: "dropbox-upload-file",
10
- version: "0.0.12",
11
+ version: "0.0.13",
11
12
  type: "action",
12
13
  props: {
13
14
  dropbox,
@@ -23,8 +24,8 @@ export default {
23
24
  },
24
25
  name: {
25
26
  type: "string",
26
- label: "File name",
27
- description: "The name of your new file.",
27
+ label: "File Name",
28
+ description: "The name of your new file (make sure to include the file extension).",
28
29
  },
29
30
  fileUrl: {
30
31
  type: "string",
@@ -77,6 +78,10 @@ export default {
77
78
  clientModified,
78
79
  } = this;
79
80
 
81
+ if (!fileUrl && !filePath) {
82
+ throw new ConfigurationError("Must specify either File URL or File Path.");
83
+ }
84
+
80
85
  const contents = fileUrl
81
86
  ? await got.stream(fileUrl)
82
87
  : fs.createReadStream(filePath);
@@ -0,0 +1,135 @@
1
+ import dropbox from "../../dropbox.app.mjs";
2
+ import consts from "../../common/consts.mjs";
3
+ import fs from "fs";
4
+ import got from "got";
5
+ import { ConfigurationError } from "@pipedream/platform";
6
+
7
+ export default {
8
+ name: "Upload Multiple Files",
9
+ description: "Uploads multiple file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
10
+ key: "dropbox-upload-multiple-files",
11
+ version: "0.0.1",
12
+ type: "action",
13
+ props: {
14
+ dropbox,
15
+ path: {
16
+ propDefinition: [
17
+ dropbox,
18
+ "path",
19
+ () => ({
20
+ filter: ({ metadata: { metadata: { [".tag"]: type } } }) => type === "folder",
21
+ }),
22
+ ],
23
+ description: "The folder to upload to. Type the folder name to search for it in the user's Dropbox.",
24
+ },
25
+ fileUrls: {
26
+ type: "string[]",
27
+ label: "File URLs",
28
+ description: "The URLs of the files you want to upload to Dropbox. Must specify either File URLs or File Paths.",
29
+ default: [],
30
+ optional: true,
31
+ },
32
+ filePaths: {
33
+ type: "string[]",
34
+ label: "File Paths",
35
+ description: "The paths to the files, e.g. /tmp/myFile.csv . Must specify either File URLs or File Paths.",
36
+ default: [],
37
+ optional: true,
38
+ },
39
+ filenames: {
40
+ type: "string[]",
41
+ label: "File Names",
42
+ description: "An array of filenames for the new files. Please provide a name for each URL and/or Path. Make sure to include the file extensions.",
43
+ },
44
+ autorename: {
45
+ type: "boolean",
46
+ label: "Autorename",
47
+ description: "If there's a conflict, have Dropbox try to autorename the file to avoid the conflict.",
48
+ optional: true,
49
+ },
50
+ mute: {
51
+ type: "boolean",
52
+ label: "Mute",
53
+ description: "Normally, users are made aware of any file modifications in their Dropbox account via notifications in the client software. If `true`, this will not result in a user notification.",
54
+ optional: true,
55
+ },
56
+ strictConflict: {
57
+ type: "boolean",
58
+ label: "Strict Conflict",
59
+ description: "Be more strict about how each WriteMode detects conflict. For example, always return a conflict error when mode = WriteMode.update and the given \"rev\" doesn't match the existing file's \"rev\", even if the existing file has been deleted. This also forces a conflict even when the target path refers to a file with identical contents.",
60
+ optional: true,
61
+ },
62
+ mode: {
63
+ type: "string",
64
+ label: "Mode",
65
+ description: "Selects what to do if the file already exists.",
66
+ options: consts.UPLOAD_FILE_MODE_OPTIONS,
67
+ optional: true,
68
+ },
69
+ },
70
+ async run({ $ }) {
71
+ const {
72
+ dropbox,
73
+ path,
74
+ fileUrls,
75
+ filePaths,
76
+ autorename,
77
+ mute,
78
+ strictConflict,
79
+ mode,
80
+ filenames,
81
+ } = this;
82
+
83
+ if (!fileUrls?.length && !filePaths?.length) {
84
+ throw new ConfigurationError("Must specify either File URLs or File Paths.");
85
+ }
86
+
87
+ const numFiles = fileUrls.length + filePaths.length;
88
+ if (numFiles !== filenames.length) {
89
+ throw new ConfigurationError(`Number of filenames must match number of files. Detected ${numFiles} file(s) and ${filenames.length} filename(s)`);
90
+ }
91
+
92
+ const fileInfo = [];
93
+ const normalizedPath = dropbox.getNormalizedPath(path, true);
94
+ let i = 0;
95
+
96
+ if (fileUrls?.length) {
97
+ for (const url of fileUrls) {
98
+ fileInfo.push({
99
+ contents: await got.stream(url),
100
+ path: `${normalizedPath}${filenames[i]}`,
101
+ });
102
+ i++;
103
+ }
104
+ }
105
+
106
+ if (filePaths?.length) {
107
+ for (const filePath of filePaths) {
108
+ fileInfo.push({
109
+ contents: fs.createReadStream(filePath),
110
+ path: `${normalizedPath}${filenames[i]}`,
111
+ });
112
+ i++;
113
+ }
114
+ }
115
+
116
+ const responses = [];
117
+ for (const file of fileInfo) {
118
+ const { result } = await dropbox.uploadFile({
119
+ contents: file.contents,
120
+ autorename,
121
+ path: file.path,
122
+ mode: mode
123
+ ? {
124
+ ".tag": mode,
125
+ }
126
+ : undefined,
127
+ mute,
128
+ strict_conflict: strictConflict,
129
+ });
130
+ responses.push(result);
131
+ }
132
+ $.export("$summary", "Files successfully uploaded");
133
+ return responses;
134
+ },
135
+ };
package/common/consts.mjs CHANGED
@@ -23,7 +23,6 @@ export default {
23
23
  LIST_FILE_REVISIONS_OPTIONS: [
24
24
  "path",
25
25
  "id",
26
- "other",
27
26
  ],
28
27
  CREATE_SHARED_LINK_AUDIENCE_OPTIONS: [
29
28
  "public",
@@ -34,10 +33,22 @@ export default {
34
33
  "other",
35
34
  ],
36
35
  CREATE_SHARED_LINK_ACCESS_OPTIONS: [
37
- "viewer",
38
- "editor",
39
- "max",
40
- "other",
36
+ {
37
+ value: "viewer",
38
+ label: "Users who use the link can view and comment on the content",
39
+ },
40
+ {
41
+ value: "editor",
42
+ label: "Users who use the link can edit, view and comment on the content. Note, not all file types support edit links yet.",
43
+ },
44
+ {
45
+ value: "max",
46
+ label: "Request for the maximum access level you can set the link to",
47
+ },
48
+ {
49
+ value: "default",
50
+ label: "Request for the default access level the user has set",
51
+ },
41
52
  ],
42
53
  CREATE_SHARED_LINK_REQUESTED_VISIBILITY_OPTIONS: [
43
54
  "public",
package/dropbox.app.mjs CHANGED
@@ -190,7 +190,7 @@ export default {
190
190
  const revisions = await dpx.filesListRevisions({
191
191
  path,
192
192
  mode: {
193
- ".tag": "id",
193
+ ".tag": "path",
194
194
  },
195
195
  });
196
196
  return revisions.result?.entries?.map((revision) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/dropbox",
3
- "version": "0.3.19",
3
+ "version": "0.4.0",
4
4
  "description": "Pipedream Dropbox Components",
5
5
  "main": "dropbox.app.mjs",
6
6
  "keywords": [
@@ -1,4 +1,5 @@
1
1
  import common from "../common/common.mjs";
2
+ import sampleEmit from "./test-event.mjs";
2
3
 
3
4
  export default {
4
5
  ...common,
@@ -6,7 +7,7 @@ export default {
6
7
  type: "source",
7
8
  key: "dropbox-all-updates",
8
9
  name: "New or Modified File or Folder",
9
- version: "0.0.16",
10
+ version: "0.0.17",
10
11
  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
12
  props: {
12
13
  ...common.props,
@@ -25,14 +26,20 @@ export default {
25
26
  },
26
27
  hooks: {
27
28
  async activate() {
28
- await this.getHistoricalEvents([
29
- "file",
30
- "folder",
31
- ]);
29
+ await this.getHistoricalEvents(this.getFileTypes());
32
30
  const state = await this.dropbox.initState(this);
33
31
  this._setDropboxState(state);
34
32
  },
35
33
  },
34
+ methods: {
35
+ ...common.methods,
36
+ getFileTypes() {
37
+ return [
38
+ "file",
39
+ "folder",
40
+ ];
41
+ },
42
+ },
36
43
  async run() {
37
44
  const state = this._getDropboxState();
38
45
  const {
@@ -43,10 +50,14 @@ export default {
43
50
  let file = {
44
51
  ...update,
45
52
  };
46
- if (this.includeMediaInfo) {
53
+ const fileTypes = this.getFileTypes();
54
+ if (!fileTypes.includes(file[".tag"])) {
55
+ continue;
56
+ }
57
+ if (this.includeMediaInfo && file[".tag"] === "file") {
47
58
  file = await this.getMediaInfo(update);
48
59
  }
49
- if (this.includeLink) {
60
+ if (this.includeLink && file[".tag"] === "file") {
50
61
  file.link = await this.getTemporaryLink(update);
51
62
  }
52
63
  // new unique identification from merging the file id and the last file revision
@@ -56,4 +67,5 @@ export default {
56
67
  this.$emit(file, this.getMeta(id, file.path_display || file.id));
57
68
  }
58
69
  },
70
+ sampleEmit,
59
71
  };
@@ -0,0 +1,14 @@
1
+ export default {
2
+ ".tag": "file",
3
+ "name": "Document.docx",
4
+ "path_lower": "/document.docx",
5
+ "path_display": "/Document.docx",
6
+ "id": "id:yVswVBnnL7cAAAAAAAAAdg",
7
+ "client_modified": "2023-04-27T17:50:32Z",
8
+ "server_modified": "2023-07-17T19:28:05Z",
9
+ "rev": "01600b3cc31f26000000002574cf900",
10
+ "size": 10468,
11
+ "is_downloadable": true,
12
+ "content_hash": "065e09a66c9bb9264a6657083c9e7a06f8e2e9bc6a5420900c737250ed108147",
13
+ "link": "https://uc2aea9ca1ec13663730d4f924d1.dl.dropboxusercontent.com/cd/0/get/CWzN/file"
14
+ }
@@ -44,7 +44,7 @@ export default {
44
44
  if (!fileTypes.includes(file[".tag"])) {
45
45
  continue;
46
46
  }
47
- if (this.includeLink) {
47
+ if (this.includeLink && file[".tag"] === "file") {
48
48
  file.link = await this.getTemporaryLink(file);
49
49
  }
50
50
  this.$emit(file, this.getMeta(file.id, file.path_display || file.id));
@@ -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.17",
10
+ version: "0.0.18",
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,
@@ -1,4 +1,5 @@
1
1
  import common from "../common/common.mjs";
2
+ import sampleEmit from "./test-event.mjs";
2
3
 
3
4
  export default {
4
5
  ...common,
@@ -6,7 +7,7 @@ export default {
6
7
  type: "source",
7
8
  key: "dropbox-new-folder",
8
9
  name: "New Folder",
9
- version: "0.0.16",
10
+ version: "0.0.17",
10
11
  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
12
  hooks: {
12
13
  async activate() {
@@ -30,4 +31,5 @@ export default {
30
31
  this.$emit(update, this.getMeta(update.id, update.path_display || update.id));
31
32
  }
32
33
  },
34
+ sampleEmit,
33
35
  };
@@ -0,0 +1,14 @@
1
+ export default {
2
+ ".tag": "folder",
3
+ "name": "Clients",
4
+ "path_lower": "/clients",
5
+ "path_display": "/Clients",
6
+ "id": "id:yVswVBnnL7cAAAAAAAAAbQ",
7
+ "shared_folder_id": "4005125857",
8
+ "sharing_info": {
9
+ "read_only": false,
10
+ "shared_folder_id": "4005125857",
11
+ "traverse_only": false,
12
+ "no_access": false
13
+ }
14
+ }