@pipedream/dropbox 0.3.4 → 0.3.6
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.
- package/README.md +15 -0
- package/actions/{common.mjs → common/common.mjs} +0 -0
- package/actions/create-a-text-file/create-a-text-file.mjs +2 -2
- package/actions/create-folder/create-folder.mjs +2 -2
- package/actions/create-or-append-to-a-text-file/create-or-append-to-a-text-file.mjs +2 -2
- package/actions/create-update-share-link/create-update-share-link.mjs +3 -3
- package/actions/delete-file-folder/delete-file-folder.mjs +2 -2
- package/actions/list-file-folders-in-a-folder/list-file-folders-in-a-folder.mjs +1 -1
- package/actions/list-file-revisions/list-file-revisions.mjs +2 -2
- package/actions/move-file-folder/move-file-folder.mjs +1 -1
- package/actions/rename-file-folder/rename-file-folder.mjs +1 -1
- package/actions/restore-a-file/restore-a-file.mjs +1 -1
- package/actions/search-files-folders/search-files-folders.mjs +2 -2
- package/actions/upload-file/upload-file.mjs +4 -4
- package/{config.mjs → common/config.mjs} +0 -0
- package/{consts.mjs → common/consts.mjs} +0 -0
- package/dropbox.app.mjs +13 -13
- package/package.json +1 -1
- package/sources/all-updates/all-updates.mjs +20 -7
- package/sources/{common.mjs → common/common.mjs} +25 -6
- package/sources/new-file/new-file.mjs +12 -4
- package/sources/new-folder/new-folder.mjs +16 -3
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
With the Dropbox API, you can build a variety of applications that range from
|
|
4
|
+
simple file sharing to complex content management systems. Some examples of
|
|
5
|
+
what you can build using the Dropbox API include:
|
|
6
|
+
|
|
7
|
+
- A file sharing application that allows users to share and sync files across
|
|
8
|
+
devices
|
|
9
|
+
- A content management system that allows users to manage and share files and
|
|
10
|
+
folders
|
|
11
|
+
- A note taking application that allows users to sync notes across devices
|
|
12
|
+
- A task management application that allows users to manage and share tasks and
|
|
13
|
+
files
|
|
14
|
+
- A document management application that allows users to manage and share
|
|
15
|
+
documents and files
|
|
File without changes
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import dropbox from "../../dropbox.app.mjs";
|
|
2
|
-
import common from "../common.mjs";
|
|
2
|
+
import common from "../common/common.mjs";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
...common,
|
|
6
6
|
name: "Create a Text File",
|
|
7
7
|
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
8
|
key: "dropbox-create-a-text-file",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.4",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
dropbox,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import dropbox from "../../dropbox.app.mjs";
|
|
2
|
-
import common from "../common.mjs";
|
|
2
|
+
import common from "../common/common.mjs";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
...common,
|
|
6
6
|
name: "Create folder",
|
|
7
7
|
description: "Create a folder. [See docs here](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCreateFolderV2__anchor)",
|
|
8
8
|
key: "dropbox-create-folder",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.4",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
dropbox,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import dropbox from "../../dropbox.app.mjs";
|
|
2
|
-
import common from "../common.mjs";
|
|
2
|
+
import common from "../common/common.mjs";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
name: "Create or Append to a Text File",
|
|
6
6
|
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
7
|
key: "dropbox-create-or-append-to-a-text-file",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
dropbox,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import dropbox from "../../dropbox.app.mjs";
|
|
2
|
-
import consts from "../../consts.mjs";
|
|
2
|
+
import consts from "../../common/consts.mjs";
|
|
3
3
|
|
|
4
4
|
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
|
-
key: "dropbox-create-update-
|
|
8
|
-
version: "0.0.
|
|
7
|
+
key: "dropbox-create-update-share-link",
|
|
8
|
+
version: "0.0.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
dropbox,
|
|
@@ -3,8 +3,8 @@ import dropbox from "../../dropbox.app.mjs";
|
|
|
3
3
|
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
|
-
key: "dropbox-delete-
|
|
7
|
-
version: "0.0.
|
|
6
|
+
key: "dropbox-delete-file-folder",
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
dropbox,
|
|
@@ -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.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
dropbox,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import consts from "../../consts.mjs";
|
|
1
|
+
import consts from "../../common/consts.mjs";
|
|
2
2
|
import dropbox from "../../dropbox.app.mjs";
|
|
3
3
|
|
|
4
4
|
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.
|
|
8
|
+
version: "0.0.4",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
dropbox,
|
|
@@ -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.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
dropbox,
|
|
@@ -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.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
dropbox,
|
|
@@ -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.
|
|
7
|
+
version: "0.0.4",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
dropbox,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import dropbox from "../../dropbox.app.mjs";
|
|
2
2
|
import isNil from "lodash/isNil.js";
|
|
3
3
|
import get from "lodash/get.js";
|
|
4
|
-
import consts from "../../consts.mjs";
|
|
4
|
+
import consts from "../../common/consts.mjs";
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
name: "Search files and folders",
|
|
8
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
9
|
key: "dropbox-search-files-folders",
|
|
10
|
-
version: "0.0.
|
|
10
|
+
version: "0.0.4",
|
|
11
11
|
type: "action",
|
|
12
12
|
props: {
|
|
13
13
|
dropbox,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import dropbox from "../../dropbox.app.mjs";
|
|
2
|
-
import consts from "../../consts.mjs";
|
|
2
|
+
import consts from "../../common/consts.mjs";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import got from "got";
|
|
5
|
-
import common from "../common.mjs";
|
|
5
|
+
import common from "../common/common.mjs";
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
...common,
|
|
9
9
|
name: "Upload a File",
|
|
10
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-
|
|
12
|
-
version: "0.0.
|
|
11
|
+
key: "dropbox-upload-file",
|
|
12
|
+
version: "0.0.5",
|
|
13
13
|
type: "action",
|
|
14
14
|
props: {
|
|
15
15
|
dropbox,
|
|
File without changes
|
|
File without changes
|
package/dropbox.app.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dropbox from "dropbox";
|
|
2
2
|
import fetch from "isomorphic-fetch";
|
|
3
3
|
import get from "lodash/get.js";
|
|
4
|
-
import config from "./config.mjs";
|
|
4
|
+
import config from "./common/config.mjs";
|
|
5
5
|
import isString from "lodash/isString.js";
|
|
6
6
|
import isEmpty from "lodash/isEmpty.js";
|
|
7
7
|
|
|
@@ -239,7 +239,6 @@ export default {
|
|
|
239
239
|
const {
|
|
240
240
|
path,
|
|
241
241
|
recursive,
|
|
242
|
-
db,
|
|
243
242
|
} = context;
|
|
244
243
|
try {
|
|
245
244
|
let fixedPath = path == "/" ?
|
|
@@ -259,11 +258,10 @@ export default {
|
|
|
259
258
|
}
|
|
260
259
|
const { cursor } = response;
|
|
261
260
|
const state = {
|
|
262
|
-
path,
|
|
261
|
+
path: fixedPath,
|
|
263
262
|
recursive,
|
|
264
263
|
cursor,
|
|
265
264
|
};
|
|
266
|
-
db.set("dropbox_state", state);
|
|
267
265
|
return state;
|
|
268
266
|
} catch (err) {
|
|
269
267
|
console.log(err);
|
|
@@ -273,24 +271,24 @@ export default {
|
|
|
273
271
|
}`;
|
|
274
272
|
}
|
|
275
273
|
},
|
|
276
|
-
async getState(context) {
|
|
274
|
+
async getState(context, state) {
|
|
277
275
|
const {
|
|
278
276
|
path,
|
|
279
277
|
recursive,
|
|
280
|
-
db,
|
|
281
278
|
} = context;
|
|
282
|
-
|
|
283
|
-
|
|
279
|
+
const fixedPath = typeof (path) === "object" ?
|
|
280
|
+
path.value :
|
|
281
|
+
path;
|
|
282
|
+
if (state == null || state.path != fixedPath || state.recursive != recursive) {
|
|
284
283
|
state = await this.initState(context);
|
|
285
284
|
}
|
|
286
285
|
return state;
|
|
287
286
|
},
|
|
288
|
-
async getUpdates(context) {
|
|
287
|
+
async getUpdates(context, dbState) {
|
|
289
288
|
let ret = [];
|
|
290
|
-
const state = await this.getState(context);
|
|
289
|
+
const state = await this.getState(context, dbState);
|
|
291
290
|
if (state) {
|
|
292
291
|
try {
|
|
293
|
-
const { db } = context;
|
|
294
292
|
let [
|
|
295
293
|
cursor,
|
|
296
294
|
hasMore,
|
|
@@ -317,13 +315,15 @@ export default {
|
|
|
317
315
|
ret = ret.concat(entries);
|
|
318
316
|
}
|
|
319
317
|
state.cursor = cursor;
|
|
320
|
-
db.set("dropbox_state", state);
|
|
321
318
|
} catch (err) {
|
|
322
319
|
console.log(err);
|
|
323
320
|
throw `Error connecting to Dropbox API to get list of updated files/folders for cursor: ${state.cursor}`;
|
|
324
321
|
}
|
|
325
322
|
}
|
|
326
|
-
return
|
|
323
|
+
return {
|
|
324
|
+
ret,
|
|
325
|
+
state,
|
|
326
|
+
};
|
|
327
327
|
},
|
|
328
328
|
async createFolder(args) {
|
|
329
329
|
try {
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import common from "../common.mjs";
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
...common,
|
|
@@ -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.
|
|
9
|
+
version: "0.0.9",
|
|
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,
|
|
@@ -23,15 +23,26 @@ export default {
|
|
|
23
23
|
default: false,
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
|
+
hooks: {
|
|
27
|
+
async activate() {
|
|
28
|
+
await this.getHistoricalEvents([
|
|
29
|
+
"file",
|
|
30
|
+
"folder",
|
|
31
|
+
]);
|
|
32
|
+
const state = await this.dropbox.initState(this);
|
|
33
|
+
this._setDropboxState(state);
|
|
34
|
+
},
|
|
35
|
+
},
|
|
26
36
|
async run() {
|
|
27
|
-
const
|
|
37
|
+
const state = this._getDropboxState();
|
|
38
|
+
const {
|
|
39
|
+
ret: updates, state: newState,
|
|
40
|
+
} = await this.dropbox.getUpdates(this, state);
|
|
41
|
+
this._setDropboxState(newState);
|
|
28
42
|
for (let update of updates) {
|
|
29
43
|
let file = {
|
|
30
44
|
...update,
|
|
31
45
|
};
|
|
32
|
-
if (update[".tag"] !== "file") {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
46
|
if (this.includeMediaInfo) {
|
|
36
47
|
file = await this.getMediaInfo(update);
|
|
37
48
|
}
|
|
@@ -39,7 +50,9 @@ export default {
|
|
|
39
50
|
file.link = await this.getTemporaryLink(update);
|
|
40
51
|
}
|
|
41
52
|
// new unique identification from merging the file id and the last file revision
|
|
42
|
-
const id =
|
|
53
|
+
const id = update[".tag"] === "file"
|
|
54
|
+
? `${file.id}-${file.rev}`
|
|
55
|
+
: `${file.id}-${newState.cursor}`;
|
|
43
56
|
this.$emit(file, this.getMeta(id, file.path_display || file.id));
|
|
44
57
|
}
|
|
45
58
|
},
|
|
@@ -22,17 +22,36 @@ export default {
|
|
|
22
22
|
static: [],
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
-
hooks: {
|
|
26
|
-
async activate() {
|
|
27
|
-
await this.dropbox.initState(this);
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
25
|
methods: {
|
|
26
|
+
_getDropboxState() {
|
|
27
|
+
return this.db.get("dropbox_state");
|
|
28
|
+
},
|
|
29
|
+
_setDropboxState(state) {
|
|
30
|
+
this.db.set("dropbox_state", state);
|
|
31
|
+
},
|
|
32
|
+
async getHistoricalEvents(fileTypes = []) {
|
|
33
|
+
const files = await this.dropbox.listFilesFolders({
|
|
34
|
+
path: this.path?.value || this.path,
|
|
35
|
+
recursive: this.recursive,
|
|
36
|
+
include_media_info: this.includeMediaInfo,
|
|
37
|
+
});
|
|
38
|
+
let count = 0;
|
|
39
|
+
for (const file of files) {
|
|
40
|
+
if (!fileTypes.includes(file[".tag"])) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
this.$emit(file, this.getMeta(file.id, file.path_display || file.id));
|
|
44
|
+
count++;
|
|
45
|
+
if (count >= 25) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
31
50
|
getMeta(id, summary) {
|
|
32
51
|
return {
|
|
33
52
|
id,
|
|
34
53
|
summary,
|
|
35
|
-
|
|
54
|
+
ts: Date.now(),
|
|
36
55
|
};
|
|
37
56
|
},
|
|
38
57
|
async isNewFile(update, lastFileModTime) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import common from "../common.mjs";
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
...common,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
type: "source",
|
|
7
7
|
key: "dropbox-new-file",
|
|
8
8
|
name: "New File",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.9",
|
|
10
10
|
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.",
|
|
11
11
|
props: {
|
|
12
12
|
...common.props,
|
|
@@ -25,9 +25,13 @@ export default {
|
|
|
25
25
|
},
|
|
26
26
|
hooks: {
|
|
27
27
|
async activate() {
|
|
28
|
+
await this.getHistoricalEvents([
|
|
29
|
+
"file",
|
|
30
|
+
]);
|
|
28
31
|
const startTime = new Date();
|
|
29
|
-
await this.dropbox.initState(this);
|
|
32
|
+
const state = await this.dropbox.initState(this);
|
|
30
33
|
this._setLastFileModTime(startTime);
|
|
34
|
+
this._setDropboxState(state);
|
|
31
35
|
},
|
|
32
36
|
},
|
|
33
37
|
methods: {
|
|
@@ -41,8 +45,12 @@ export default {
|
|
|
41
45
|
},
|
|
42
46
|
async run() {
|
|
43
47
|
const lastFileModTime = this._getLastFileModTime();
|
|
48
|
+
const state = this._getDropboxState();
|
|
44
49
|
let currFileModTime = "";
|
|
45
|
-
const
|
|
50
|
+
const {
|
|
51
|
+
ret: updates, state: newState,
|
|
52
|
+
} = await this.dropbox.getUpdates(this, state);
|
|
53
|
+
this._setDropboxState(newState);
|
|
46
54
|
for (let update of updates) {
|
|
47
55
|
let file = {
|
|
48
56
|
...update,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import common from "../common.mjs";
|
|
1
|
+
import common from "../common/common.mjs";
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
...common,
|
|
@@ -6,10 +6,23 @@ export default {
|
|
|
6
6
|
type: "source",
|
|
7
7
|
key: "dropbox-new-folder",
|
|
8
8
|
name: "New Folder",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.9",
|
|
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
|
+
hooks: {
|
|
12
|
+
async activate() {
|
|
13
|
+
await this.getHistoricalEvents([
|
|
14
|
+
"folder",
|
|
15
|
+
]);
|
|
16
|
+
const state = await this.dropbox.initState(this);
|
|
17
|
+
this._setDropboxState(state);
|
|
18
|
+
},
|
|
19
|
+
},
|
|
11
20
|
async run() {
|
|
12
|
-
const
|
|
21
|
+
const state = this._getDropboxState();
|
|
22
|
+
const {
|
|
23
|
+
ret: updates, state: newState,
|
|
24
|
+
} = await this.dropbox.getUpdates(this, state);
|
|
25
|
+
this._setDropboxState(newState);
|
|
13
26
|
for (const update of updates) {
|
|
14
27
|
if (update[".tag"] !== "folder") {
|
|
15
28
|
continue;
|