@pipedream/dropbox 0.3.4 → 0.3.5

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 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
@@ -6,7 +6,7 @@ export default {
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.2",
9
+ version: "0.0.3",
10
10
  type: "action",
11
11
  props: {
12
12
  dropbox,
@@ -6,7 +6,7 @@ export default {
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.2",
9
+ version: "0.0.3",
10
10
  type: "action",
11
11
  props: {
12
12
  dropbox,
@@ -5,7 +5,7 @@ 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.2",
8
+ version: "0.0.3",
9
9
  type: "action",
10
10
  props: {
11
11
  dropbox,
@@ -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-update-a-share-link",
8
- version: "0.0.2",
8
+ version: "0.0.3",
9
9
  type: "action",
10
10
  props: {
11
11
  dropbox,
@@ -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-a-file-folder",
7
- version: "0.0.2",
7
+ version: "0.0.3",
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.2",
7
+ version: "0.0.3",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -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.2",
8
+ version: "0.0.3",
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.2",
7
+ version: "0.0.3",
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.2",
7
+ version: "0.0.3",
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.2",
7
+ version: "0.0.3",
8
8
  type: "action",
9
9
  props: {
10
10
  dropbox,
@@ -7,7 +7,7 @@ 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.2",
10
+ version: "0.0.3",
11
11
  type: "action",
12
12
  props: {
13
13
  dropbox,
@@ -9,7 +9,7 @@ export default {
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
11
  key: "dropbox-upload-a-file",
12
- version: "0.0.3",
12
+ version: "0.0.4",
13
13
  type: "action",
14
14
  props: {
15
15
  dropbox,
package/dropbox.app.mjs CHANGED
@@ -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
- let state = db.get("dropbox_state");
283
- if (state == null || state.path != path || state.recursive != recursive) {
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 ret;
323
+ return {
324
+ ret,
325
+ state,
326
+ };
327
327
  },
328
328
  async createFolder(args) {
329
329
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/dropbox",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Pipedream Dropbox Components",
5
5
  "main": "dropbox.app.js",
6
6
  "keywords": [
@@ -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.7",
9
+ version: "0.0.8",
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 updates = await this.dropbox.getUpdates(this);
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 = `${file.id}-${file.rev}`;
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
- tz: Date.now(),
54
+ ts: Date.now(),
36
55
  };
37
56
  },
38
57
  async isNewFile(update, lastFileModTime) {
@@ -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.7",
9
+ version: "0.0.8",
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 updates = await this.dropbox.getUpdates(this);
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,
@@ -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.7",
9
+ version: "0.0.8",
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 updates = await this.dropbox.getUpdates(this);
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;