@pipedream/dropbox 0.3.3 → 0.3.4

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.
@@ -0,0 +1,117 @@
1
+ import dropbox from "../../dropbox.app.mjs";
2
+ import isNil from "lodash/isNil.js";
3
+ import get from "lodash/get.js";
4
+ import consts from "../../consts.mjs";
5
+
6
+ export default {
7
+ name: "Search files and folders",
8
+ description: "Searches for files and folders by name. [See the docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesSearchV2__anchor)",
9
+ key: "dropbox-search-files-folders",
10
+ version: "0.0.2",
11
+ type: "action",
12
+ props: {
13
+ dropbox,
14
+ query: {
15
+ propDefinition: [
16
+ dropbox,
17
+ "query",
18
+ ],
19
+ },
20
+ path: {
21
+ propDefinition: [
22
+ dropbox,
23
+ "pathFolder",
24
+ ],
25
+ optional: true,
26
+ description: "Scopes the search to a path in the user's Dropbox. Searches the entire Dropbox if not specified.",
27
+ },
28
+ orderBy: {
29
+ type: "string",
30
+ label: "Order by",
31
+ description: "By default, results are sorted by relevance.",
32
+ optional: true,
33
+ options: consts.SEARCH_FILE_FOLDER_ORDER_BY_OPTIONS,
34
+ },
35
+ fileStatus: {
36
+ type: "string",
37
+ label: "File status",
38
+ description: "Restricts search to the given file status.",
39
+ optional: true,
40
+ options: consts.SEARCH_FILE_FOLDER_STATUS_OPTIONS,
41
+ },
42
+ filenameOnly: {
43
+ type: "boolean",
44
+ label: "Filename only",
45
+ description: "Restricts search to only match on filenames.",
46
+ optional: true,
47
+ },
48
+ fileCategories: {
49
+ type: "string[]",
50
+ label: "File categories",
51
+ description: "Restricts search to only the file categories specified. Only supported for active file search.",
52
+ optional: true,
53
+ options: consts.FILES_CATEGORIES_OPTIONS,
54
+ },
55
+ fileExtensions: {
56
+ type: "string[]",
57
+ label: "File extensions",
58
+ description: "Restricts search to only the extensions specified. Only supported for active file search.",
59
+ optional: true,
60
+ },
61
+ includeHighlights: {
62
+ type: "boolean",
63
+ label: "Include highlights",
64
+ description: "Whether to include highlight span from file title.",
65
+ optional: true,
66
+ },
67
+ limit: {
68
+ propDefinition: [
69
+ dropbox,
70
+ "limit",
71
+ ],
72
+ },
73
+ },
74
+ async run({ $ }) {
75
+ const {
76
+ query,
77
+ includeHighlights,
78
+ limit,
79
+ path,
80
+ orderBy,
81
+ fileStatus,
82
+ filenameOnly,
83
+ fileExtensions,
84
+ fileCategories,
85
+ } = this;
86
+ const res = await this.dropbox.searchFilesFolders({
87
+ query,
88
+ match_field_options: !isNil(includeHighlights)
89
+ ? undefined
90
+ : {
91
+ include_highlights: includeHighlights,
92
+ },
93
+ options: {
94
+ path: get(path, "value", path) || "",
95
+ order_by: orderBy
96
+ ? {
97
+ ".tag": orderBy,
98
+ }
99
+ : undefined,
100
+ file_status: fileStatus
101
+ ? {
102
+ ".tag": fileStatus,
103
+ }
104
+ : undefined,
105
+ filename_only: filenameOnly,
106
+ file_extensions: fileExtensions,
107
+ file_categories: fileCategories
108
+ ? fileCategories.map((category) => ({
109
+ ".tag": category,
110
+ }))
111
+ : undefined,
112
+ },
113
+ }, limit);
114
+ $.export("$summary", "Files and folders successfully fetched");
115
+ return res;
116
+ },
117
+ };
@@ -0,0 +1,101 @@
1
+ import dropbox from "../../dropbox.app.mjs";
2
+ import consts from "../../consts.mjs";
3
+ import fs from "fs";
4
+ import got from "got";
5
+ import common from "../common.mjs";
6
+
7
+ export default {
8
+ ...common,
9
+ name: "Upload a File",
10
+ description: "Uploads a file to a selected folder. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)",
11
+ key: "dropbox-upload-a-file",
12
+ version: "0.0.3",
13
+ type: "action",
14
+ props: {
15
+ dropbox,
16
+ path: {
17
+ propDefinition: [
18
+ dropbox,
19
+ "pathFolder",
20
+ ],
21
+ description: "The file path in the user's Dropbox to create the file. If not filled, it will be created in the root folder.",
22
+ },
23
+ name: {
24
+ type: "string",
25
+ label: "File name",
26
+ description: "The name of your new file.",
27
+ },
28
+ fileUrl: {
29
+ type: "string",
30
+ label: "File URL",
31
+ description: "The URL of the file you want to upload to Dropbox. Must specify either File URL or File Path.",
32
+ optional: true,
33
+ },
34
+ filePath: {
35
+ type: "string",
36
+ label: "File Path",
37
+ description: "The path to the file, e.g. /tmp/myFile.csv . Must specify either File URL or File Path.",
38
+ optional: true,
39
+ },
40
+ autorename: {
41
+ type: "boolean",
42
+ label: "Autorename",
43
+ description: "If there's a conflict, have Dropbox try to autorename the folder to avoid the conflict.",
44
+ optional: true,
45
+ },
46
+ mute: {
47
+ type: "boolean",
48
+ label: "Mute",
49
+ 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.",
50
+ optional: true,
51
+ },
52
+ strictConflict: {
53
+ type: "boolean",
54
+ label: "Strict Conflict",
55
+ 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.",
56
+ optional: true,
57
+ },
58
+ mode: {
59
+ type: "string",
60
+ label: "Mode",
61
+ description: "Selects what to do if the file already exists.",
62
+ options: consts.UPLOAD_FILE_MODE_OPTIONS,
63
+ optional: true,
64
+ },
65
+ },
66
+ async run({ $ }) {
67
+ const {
68
+ fileUrl,
69
+ filePath,
70
+ path,
71
+ name,
72
+ autorename,
73
+ mute,
74
+ strictConflict,
75
+ mode,
76
+ clientModified,
77
+ } = this;
78
+
79
+ const contents = fileUrl
80
+ ? await got.stream(fileUrl)
81
+ : fs.createReadStream(filePath);
82
+
83
+ let normalizedPath = this.getNormalizedPath(path, true);
84
+
85
+ const res = await this.dropbox.uploadFile({
86
+ contents,
87
+ autorename,
88
+ path: normalizedPath + name,
89
+ mode: mode
90
+ ? {
91
+ ".tag": mode,
92
+ }
93
+ : undefined,
94
+ client_modified: clientModified,
95
+ mute,
96
+ strict_conflict: strictConflict,
97
+ });
98
+ $.export("$summary", `File successfully uploaded to "${path?.label || path}"`);
99
+ return res;
100
+ },
101
+ };
package/config.mjs ADDED
@@ -0,0 +1,11 @@
1
+ export default {
2
+ SEARCH_FILE_FOLDERS: {
3
+ DEFAULT_MAX_RESULTS: 100,
4
+ },
5
+ LIST_FILES_IN_FOLDER: {
6
+ DEFAULT_MAX_RESULTS: 100,
7
+ },
8
+ GET_PATH_OPTIONS: {
9
+ DEFAULT_MAX_RESULTS: 1000,
10
+ },
11
+ };
package/consts.mjs ADDED
@@ -0,0 +1,52 @@
1
+ export default {
2
+ SEARCH_FILE_FOLDER_ORDER_BY_OPTIONS: [
3
+ "relevance",
4
+ "last_modified_time",
5
+ ],
6
+ SEARCH_FILE_FOLDER_STATUS_OPTIONS: [
7
+ "active",
8
+ "deleted",
9
+ ],
10
+ FILES_CATEGORIES_OPTIONS: [
11
+ "image",
12
+ "document",
13
+ "pdf",
14
+ "spreadsheet",
15
+ "presentation",
16
+ "audio",
17
+ "video",
18
+ "folder",
19
+ "paper",
20
+ "others",
21
+ "other",
22
+ ],
23
+ LIST_FILE_REVISIONS_OPTIONS: [
24
+ "path",
25
+ "id",
26
+ "other",
27
+ ],
28
+ CREATE_SHARED_LINK_AUDIENCE_OPTIONS: [
29
+ "public",
30
+ "team",
31
+ "no_one",
32
+ "password",
33
+ "members",
34
+ "other",
35
+ ],
36
+ CREATE_SHARED_LINK_ACCESS_OPTIONS: [
37
+ "viewer",
38
+ "editor",
39
+ "max",
40
+ "other",
41
+ ],
42
+ CREATE_SHARED_LINK_REQUESTED_VISIBILITY_OPTIONS: [
43
+ "public",
44
+ "team_only",
45
+ "password",
46
+ ],
47
+ UPLOAD_FILE_MODE_OPTIONS: [
48
+ "add",
49
+ "overwrite",
50
+ "update",
51
+ ],
52
+ };