diff --git a/components/dropbox/actions/create-a-text-file/create-a-text-file.mjs b/components/dropbox/actions/create-a-text-file/create-a-text-file.mjs index 006b99ad757c8..e46715b168958 100644 --- a/components/dropbox/actions/create-a-text-file/create-a-text-file.mjs +++ b/components/dropbox/actions/create-a-text-file/create-a-text-file.mjs @@ -4,7 +4,7 @@ export default { name: "Create a Text File", 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)", key: "dropbox-create-a-text-file", - version: "0.0.10", + version: "0.0.11", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/create-folder/create-folder.mjs b/components/dropbox/actions/create-folder/create-folder.mjs index 98eda414d04b9..289b9a040fbc2 100644 --- a/components/dropbox/actions/create-folder/create-folder.mjs +++ b/components/dropbox/actions/create-folder/create-folder.mjs @@ -4,7 +4,7 @@ export default { name: "Create folder", description: "Create a Folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesCreateFolderV2__anchor)", key: "dropbox-create-folder", - version: "0.0.10", + version: "0.0.11", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/create-or-append-to-a-text-file/create-or-append-to-a-text-file.mjs b/components/dropbox/actions/create-or-append-to-a-text-file/create-or-append-to-a-text-file.mjs index a0edb5a976b28..5a65d54eddaf2 100644 --- a/components/dropbox/actions/create-or-append-to-a-text-file/create-or-append-to-a-text-file.mjs +++ b/components/dropbox/actions/create-or-append-to-a-text-file/create-or-append-to-a-text-file.mjs @@ -4,7 +4,7 @@ export default { name: "Create or Append to a Text File", 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)", key: "dropbox-create-or-append-to-a-text-file", - version: "0.0.10", + version: "0.0.11", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/create-update-share-link/create-update-share-link.mjs b/components/dropbox/actions/create-update-share-link/create-update-share-link.mjs index 307df74d48702..ba83351f5e9ee 100644 --- a/components/dropbox/actions/create-update-share-link/create-update-share-link.mjs +++ b/components/dropbox/actions/create-update-share-link/create-update-share-link.mjs @@ -1,11 +1,11 @@ -import common from "./common.mjs"; import consts from "../../common/consts.mjs"; +import common from "./common.mjs"; export default { name: "Create/Update a Share Link", 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)", key: "dropbox-create-update-share-link", - version: "0.0.10", + version: "0.0.11", type: "action", props: { ...common.props, diff --git a/components/dropbox/actions/delete-file-folder/delete-file-folder.mjs b/components/dropbox/actions/delete-file-folder/delete-file-folder.mjs index 53877d72907d0..9f145826ed36e 100644 --- a/components/dropbox/actions/delete-file-folder/delete-file-folder.mjs +++ b/components/dropbox/actions/delete-file-folder/delete-file-folder.mjs @@ -4,7 +4,7 @@ export default { name: "Delete a File/Folder", description: "Permanently removes a file/folder from the server. [See documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDeleteV2__anchor)", key: "dropbox-delete-file-folder", - version: "0.0.10", + version: "0.0.11", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/download-file-to-tmp/download-file-to-tmp.mjs b/components/dropbox/actions/download-file-to-tmp/download-file-to-tmp.mjs index 5ca57f678eab3..eaec9174951ca 100644 --- a/components/dropbox/actions/download-file-to-tmp/download-file-to-tmp.mjs +++ b/components/dropbox/actions/download-file-to-tmp/download-file-to-tmp.mjs @@ -1,12 +1,15 @@ -import dropbox from "../../dropbox.app.mjs"; import fs from "fs"; -import { file } from "tmp-promise"; +import got from "got"; +import stream from "stream"; +import { promisify } from "util"; +import { checkTmp } from "../../common/utils.mjs"; +import dropbox from "../../dropbox.app.mjs"; export default { name: "Download File to TMP", description: "Download a specific file to the temporary directory. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDownload__anchor).", key: "dropbox-download-file-to-tmp", - version: "0.0.6", + version: "0.0.7", type: "action", props: { dropbox, @@ -27,30 +30,40 @@ export default { }, }, async run({ $ }) { - const { result } = await this.dropbox.downloadFile({ - path: this.dropbox.getNormalizedPath(this.path, false), - }); + try { + const linkResponse = await this.dropbox.filesGetTemporaryLink({ + path: this.dropbox.getNormalizedPath(this.path, false), + }); + + console.log("linkResponse: ", linkResponse); - const { - path, cleanup, - } = await file(); + if (!linkResponse || !linkResponse.result) { + throw new Error("Failed to get temporary download link from Dropbox"); + } - const extension = result.name.split(".").pop(); + const { + link, metadata, + } = linkResponse.result; - const tmpPath = this.name - ? `/tmp/${this.name}` - : `${path}.${extension}`; + const fileName = this.name || metadata.name; + const cleanFileName = fileName.replace(/[?$#&{}[]<>\*!@:\+\\\/]/g, ""); - await fs.promises.appendFile(tmpPath, Buffer.from(result.fileBinary)); - await cleanup(); + const tmpPath = checkTmp(cleanFileName); + const pipeline = promisify(stream.pipeline); - delete result.fileBinary; + await pipeline( + got.stream(link), + fs.createWriteStream(tmpPath), + ); - $.export("$summary", `File successfully saved in "${tmpPath}"`); + $.export("$summary", `File successfully saved in "${tmpPath}"`); - return { - tmpPath, - ...result, - }; + return { + tmpPath, + ...metadata, + }; + } catch (error) { + throw new Error(`Failed to download file: ${error.message}`); + } }, }; diff --git a/components/dropbox/actions/list-file-folders-in-a-folder/list-file-folders-in-a-folder.mjs b/components/dropbox/actions/list-file-folders-in-a-folder/list-file-folders-in-a-folder.mjs index 0e0fd2a540546..dbccae8d5ea29 100644 --- a/components/dropbox/actions/list-file-folders-in-a-folder/list-file-folders-in-a-folder.mjs +++ b/components/dropbox/actions/list-file-folders-in-a-folder/list-file-folders-in-a-folder.mjs @@ -4,7 +4,7 @@ export default { name: "List All Files/Subfolders in a Folder", 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)", key: "dropbox-list-file-folders-in-a-folder", - version: "0.0.10", + version: "0.0.11", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/list-file-revisions/list-file-revisions.mjs b/components/dropbox/actions/list-file-revisions/list-file-revisions.mjs index c9b6137b263d6..84e7257ba8027 100644 --- a/components/dropbox/actions/list-file-revisions/list-file-revisions.mjs +++ b/components/dropbox/actions/list-file-revisions/list-file-revisions.mjs @@ -5,7 +5,7 @@ export default { name: "List File Revisions", 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)", key: "dropbox-list-file-revisions", - version: "0.0.10", + version: "0.0.11", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/move-file-folder/move-file-folder.mjs b/components/dropbox/actions/move-file-folder/move-file-folder.mjs index 146eccc7c265c..5dfb2422b2cb2 100644 --- a/components/dropbox/actions/move-file-folder/move-file-folder.mjs +++ b/components/dropbox/actions/move-file-folder/move-file-folder.mjs @@ -4,7 +4,7 @@ export default { name: "Move a File/Folder", 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)", key: "dropbox-move-file-folder", - version: "0.0.11", + version: "0.0.12", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/rename-file-folder/rename-file-folder.mjs b/components/dropbox/actions/rename-file-folder/rename-file-folder.mjs index ff194300ca8ca..49b15eb31a2d1 100644 --- a/components/dropbox/actions/rename-file-folder/rename-file-folder.mjs +++ b/components/dropbox/actions/rename-file-folder/rename-file-folder.mjs @@ -4,7 +4,7 @@ export default { name: "Rename a File/Folder", 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)", key: "dropbox-rename-file-folder", - version: "0.0.10", + version: "0.0.11", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/restore-a-file/restore-a-file.mjs b/components/dropbox/actions/restore-a-file/restore-a-file.mjs index 3e2253bbe4c01..ff883ba865881 100644 --- a/components/dropbox/actions/restore-a-file/restore-a-file.mjs +++ b/components/dropbox/actions/restore-a-file/restore-a-file.mjs @@ -4,7 +4,7 @@ export default { name: "Restore a File", description: "Restores a previous file version. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesRestore__anchor)", key: "dropbox-restore-a-file", - version: "0.0.10", + version: "0.0.11", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/search-files-folders/search-files-folders.mjs b/components/dropbox/actions/search-files-folders/search-files-folders.mjs index beac0b14da4ee..37b32ed1c4723 100644 --- a/components/dropbox/actions/search-files-folders/search-files-folders.mjs +++ b/components/dropbox/actions/search-files-folders/search-files-folders.mjs @@ -1,12 +1,12 @@ -import dropbox from "../../dropbox.app.mjs"; import isNil from "lodash/isNil.js"; import consts from "../../common/consts.mjs"; +import dropbox from "../../dropbox.app.mjs"; export default { name: "Search files and folders", description: "Searches for files and folders by name. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesSearchV2__anchor)", key: "dropbox-search-files-folders", - version: "0.0.10", + version: "0.0.11", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/upload-file/upload-file.mjs b/components/dropbox/actions/upload-file/upload-file.mjs index 85e5d3a3030e2..d7d4cb5821a05 100644 --- a/components/dropbox/actions/upload-file/upload-file.mjs +++ b/components/dropbox/actions/upload-file/upload-file.mjs @@ -1,14 +1,14 @@ -import dropbox from "../../dropbox.app.mjs"; -import consts from "../../common/consts.mjs"; +import { ConfigurationError } from "@pipedream/platform"; import fs from "fs"; import got from "got"; -import { ConfigurationError } from "@pipedream/platform"; +import consts from "../../common/consts.mjs"; +import dropbox from "../../dropbox.app.mjs"; export default { name: "Upload a File", description: "Uploads a file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)", key: "dropbox-upload-file", - version: "0.0.13", + version: "0.0.14", type: "action", props: { dropbox, diff --git a/components/dropbox/actions/upload-multiple-files/upload-multiple-files.mjs b/components/dropbox/actions/upload-multiple-files/upload-multiple-files.mjs index 817b0b37b7321..b1820b8e5deda 100644 --- a/components/dropbox/actions/upload-multiple-files/upload-multiple-files.mjs +++ b/components/dropbox/actions/upload-multiple-files/upload-multiple-files.mjs @@ -1,14 +1,14 @@ -import dropbox from "../../dropbox.app.mjs"; -import consts from "../../common/consts.mjs"; +import { ConfigurationError } from "@pipedream/platform"; import fs from "fs"; import got from "got"; -import { ConfigurationError } from "@pipedream/platform"; +import consts from "../../common/consts.mjs"; +import dropbox from "../../dropbox.app.mjs"; export default { name: "Upload Multiple Files", description: "Uploads multiple file to a selected folder. [See the documentation](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesUpload__anchor)", key: "dropbox-upload-multiple-files", - version: "0.0.1", + version: "0.0.2", type: "action", props: { dropbox, diff --git a/components/dropbox/common/utils.mjs b/components/dropbox/common/utils.mjs new file mode 100644 index 0000000000000..1a5e36f32a603 --- /dev/null +++ b/components/dropbox/common/utils.mjs @@ -0,0 +1,6 @@ +export const checkTmp = (filename) => { + if (!filename.startsWith("/tmp")) { + return `/tmp/${filename}`; + } + return filename; +}; diff --git a/components/dropbox/dropbox.app.mjs b/components/dropbox/dropbox.app.mjs index c88925fbdde31..21271a7e83933 100644 --- a/components/dropbox/dropbox.app.mjs +++ b/components/dropbox/dropbox.app.mjs @@ -1,12 +1,10 @@ -import dropbox from "dropbox"; +import { Dropbox } from "dropbox"; import fetch from "isomorphic-fetch"; import get from "lodash/get.js"; -import config from "./common/config.mjs"; -import isString from "lodash/isString.js"; import isEmpty from "lodash/isEmpty.js"; import isNil from "lodash/isNil.js"; - -const Dropbox = dropbox.Dropbox; +import isString from "lodash/isString.js"; +import config from "./common/config.mjs"; export default { type: "app", @@ -400,6 +398,14 @@ export default { this.normalizeError(err); } }, + async filesGetTemporaryLink(args) { + try { + const dpx = await this.sdk(); + return await dpx.filesGetTemporaryLink(args); + } catch (err) { + this.normalizeError(err); + } + }, async downloadFile(args) { try { const dpx = await this.sdk(); diff --git a/components/dropbox/package.json b/components/dropbox/package.json index 9f56f31fb5a3c..adc1d3c408d4d 100644 --- a/components/dropbox/package.json +++ b/components/dropbox/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/dropbox", - "version": "0.4.0", + "version": "0.4.1", "description": "Pipedream Dropbox Components", "main": "dropbox.app.mjs", "keywords": [ @@ -12,10 +12,12 @@ "dependencies": { "@types/node-fetch": "^2.5.7", "dropbox": "^10.34.0", - "got": "^14.0.0", + "got": "^13.0.0", "isomorphic-fetch": "^3.0.0", "lodash": "^4.17.21", - "tmp-promise": "^3.0.3" + "stream": "^0.0.3", + "tmp-promise": "^3.0.3", + "util": "^0.12.5" }, "gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535", "publishConfig": { diff --git a/components/dropbox/sources/all-updates/all-updates.mjs b/components/dropbox/sources/all-updates/all-updates.mjs index 6903ea6c64040..1405f9b083d75 100644 --- a/components/dropbox/sources/all-updates/all-updates.mjs +++ b/components/dropbox/sources/all-updates/all-updates.mjs @@ -7,7 +7,7 @@ export default { type: "source", key: "dropbox-all-updates", name: "New or Modified File or Folder", - version: "0.0.17", + version: "0.0.18", 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.", props: { ...common.props, diff --git a/components/dropbox/sources/new-file/new-file.mjs b/components/dropbox/sources/new-file/new-file.mjs index e33f4b5b9ab88..8d45236bf468f 100644 --- a/components/dropbox/sources/new-file/new-file.mjs +++ b/components/dropbox/sources/new-file/new-file.mjs @@ -7,7 +7,7 @@ export default { type: "source", key: "dropbox-new-file", name: "New File", - version: "0.0.18", + version: "0.0.19", 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.", props: { ...common.props, diff --git a/components/dropbox/sources/new-folder/new-folder.mjs b/components/dropbox/sources/new-folder/new-folder.mjs index a39817937ccf7..39a2cc9ebd0c2 100644 --- a/components/dropbox/sources/new-folder/new-folder.mjs +++ b/components/dropbox/sources/new-folder/new-folder.mjs @@ -7,7 +7,7 @@ export default { type: "source", key: "dropbox-new-folder", name: "New Folder", - version: "0.0.17", + version: "0.0.18", 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.", hooks: { async activate() { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 95f4c8424202f..b2b4c93c4a78b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3877,17 +3877,23 @@ importers: specifier: ^10.34.0 version: 10.34.0(@types/node-fetch@2.6.12) got: - specifier: ^14.0.0 - version: 14.4.4 + specifier: ^13.0.0 + version: 13.0.0 isomorphic-fetch: specifier: ^3.0.0 version: 3.0.0 lodash: specifier: ^4.17.21 version: 4.17.21 + stream: + specifier: ^0.0.3 + version: 0.0.3 tmp-promise: specifier: ^3.0.3 version: 3.0.3 + util: + specifier: ^0.12.5 + version: 0.12.5 components/dropcontact: dependencies: @@ -15575,14 +15581,6 @@ importers: specifier: ^6.0.0 version: 6.2.0 - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/cjs: {} - - modelcontextprotocol/node_modules2/@modelcontextprotocol/sdk/dist/esm: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/cjs: {} - - modelcontextprotocol/node_modules2/zod-to-json-schema/dist/esm: {} - packages/ai: dependencies: '@pipedream/sdk': @@ -24313,10 +24311,6 @@ packages: resolution: {integrity: sha512-XfBk1CxOOScDcMr9O1yKkNaQyy865NbYs+F7dr4H0LZMVgCj2Le59k6PqbNHoL5ToeaEQUYh6c6yMfVcc6SJxA==} engines: {node: '>=16'} - got@14.4.4: - resolution: {integrity: sha512-tqiF7eSgTBwQkxb1LxsEpva8TaMYVisbhplrFVmw9GQE3855Z+MH/mnsXLLOkDxR6hZJRFMj5VTAZ8lmTF8ZOA==} - engines: {node: '>=20'} - got@14.4.6: resolution: {integrity: sha512-rnhwfM/PhMNJ1i17k3DuDqgj0cKx3IHxBKVv/WX1uDKqrhi2Gv3l7rhPThR/Cc6uU++dD97W9c8Y0qyw9x0jag==} engines: {node: '>=20'} @@ -42556,20 +42550,6 @@ snapshots: p-cancelable: 3.0.0 responselike: 3.0.0 - got@14.4.4: - dependencies: - '@sindresorhus/is': 7.0.1 - '@szmarczak/http-timer': 5.0.1 - cacheable-lookup: 7.0.0 - cacheable-request: 12.0.1 - decompress-response: 6.0.0 - form-data-encoder: 4.0.2 - http2-wrapper: 2.2.1 - lowercase-keys: 3.0.0 - p-cancelable: 4.0.1 - responselike: 3.0.0 - type-fest: 4.27.0 - got@14.4.6: dependencies: '@sindresorhus/is': 7.0.1