diff --git a/components/google_drive/actions/update-file/update-file.mjs b/components/google_drive/actions/update-file/update-file.mjs index c8e748e618baf..2a027e9e0b442 100644 --- a/components/google_drive/actions/update-file/update-file.mjs +++ b/components/google_drive/actions/update-file/update-file.mjs @@ -3,19 +3,36 @@ import { toSingleLineString, getFileStream, } from "../../common/utils.mjs"; +import { additionalProps } from "../../common/filePathOrUrl.mjs"; export default { key: "google_drive-update-file", name: "Update File", description: "Update a file's metadata and/or content. [See the documentation](https://developers.google.com/drive/api/v3/reference/files/update) for more information", - version: "0.1.7", + version: "1.0.0", type: "action", + additionalProps, props: { googleDrive, - requiredPropsAlert: { - type: "alert", - alertType: "info", - content: "Either `File URL` and `File Path` should be specified.", + updateType: { + type: "string", + label: "Update Type", + description: "Whether to update content or metadata only", + options: [ + { + label: "Upload content from File URL", + value: "File URL", + }, + { + label: "Upload content from File Path", + value: "File Path", + }, + { + label: "Update file metadata only", + value: "File Metadata", + }, + ], + reloadProps: true, }, drive: { propDefinition: [ @@ -40,6 +57,8 @@ export default { "fileUrl", ], description: "The URL of the file to use to update content", + optional: false, + hidden: true, }, filePath: { propDefinition: [ @@ -51,6 +70,8 @@ export default { directory](https://pipedream.com/docs/workflows/steps/code/nodejs/working-with-files/#the-tmp-directory) (e.g., \`/tmp/myFile.csv\`) with which to update content `), + optional: false, + hidden: true, }, name: { propDefinition: [ @@ -128,16 +149,21 @@ export default { ocrLanguage, useContentAsIndexableText, advanced, + updateType, } = this; - const fileStream = - fileUrl || filePath - ? await getFileStream({ - $, - fileUrl, - filePath, - }) - : undefined; + let fileStream; + if (updateType === "File URL") { + fileStream = await getFileStream({ + $, + fileUrl, + }); + } else if (updateType === "File Path") { + fileStream = await getFileStream({ + $, + filePath, + }); + } // Update file content, if set, separately from metadata to prevent // multipart upload, which `google-apis-nodejs-client` doesn't seem to diff --git a/components/google_drive/actions/upload-file/upload-file.mjs b/components/google_drive/actions/upload-file/upload-file.mjs index ba885430adc9d..92cdbbf6e3ae4 100644 --- a/components/google_drive/actions/upload-file/upload-file.mjs +++ b/components/google_drive/actions/upload-file/upload-file.mjs @@ -5,21 +5,20 @@ import { omitEmptyStringValues, } from "../../common/utils.mjs"; import { GOOGLE_DRIVE_UPLOAD_TYPE_MULTIPART } from "../../common/constants.mjs"; -import { ConfigurationError } from "@pipedream/platform"; +import { + additionalProps, updateType, +} from "../../common/filePathOrUrl.mjs"; export default { key: "google_drive-upload-file", name: "Upload File", description: "Upload a file to Google Drive. [See the documentation](https://developers.google.com/drive/api/v3/manage-uploads) for more information", - version: "0.1.10", + version: "1.0.0", type: "action", + additionalProps, props: { googleDrive, - infoAlert: { - type: "alert", - alertType: "info", - content: "Either `File URL` and `File Path` should be specified.", - }, + updateType, drive: { propDefinition: [ googleDrive, @@ -44,12 +43,16 @@ export default { googleDrive, "fileUrl", ], + optional: false, + hidden: true, }, filePath: { propDefinition: [ googleDrive, "filePath", ], + optional: false, + hidden: true, }, name: { propDefinition: [ @@ -94,9 +97,6 @@ export default { mimeType, } = this; let { uploadType } = this; - if (!fileUrl && !filePath) { - throw new ConfigurationError("Either `File URL` and `File Path` should be specified."); - } const driveId = this.googleDrive.getDriveId(this.drive); const filename = name || path.basename(fileUrl || filePath); diff --git a/components/google_drive/common/filePathOrUrl.mjs b/components/google_drive/common/filePathOrUrl.mjs new file mode 100644 index 0000000000000..964f5580d917e --- /dev/null +++ b/components/google_drive/common/filePathOrUrl.mjs @@ -0,0 +1,27 @@ +export const updateType = { + type: "string", + label: "Use File URL or File Path", + description: "Whether to upload a file from a URL or from the `/tmp` folder", + options: [ + "File URL", + "File Path", + ], + reloadProps: true, +}; + +export async function additionalProps(previousProps) { + const { updateType } = this; + + if (updateType === "File URL") { + previousProps.fileUrl.hidden = false; + previousProps.filePath.hidden = true; + } else if (updateType === "File Path") { + previousProps.fileUrl.hidden = true; + previousProps.filePath.hidden = false; + } else { + previousProps.fileUrl.hidden = true; + previousProps.filePath.hidden = true; + } + + return {}; +} diff --git a/components/google_drive/package.json b/components/google_drive/package.json index cebdc29cc9759..24226df14c896 100644 --- a/components/google_drive/package.json +++ b/components/google_drive/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/google_drive", - "version": "0.8.9", + "version": "0.8.10", "description": "Pipedream Google_drive Components", "main": "google_drive.app.mjs", "keywords": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 85a430b83d50c..b24bc3bd143b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2454,8 +2454,7 @@ importers: specifier: ^0.1.6 version: 0.1.6 - components/current_rms: - specifiers: {} + components/current_rms: {} components/customer_fields: dependencies: @@ -7284,8 +7283,7 @@ importers: components/odoo: {} - components/office_365_management: - specifiers: {} + components/office_365_management: {} components/offlight: dependencies: @@ -12645,8 +12643,7 @@ importers: specifier: ^1.0.5 version: 1.0.5 - components/zoho_tables: - specifiers: {} + components/zoho_tables: {} components/zoho_workdrive: dependencies: @@ -14275,12 +14272,12 @@ packages: '@dabh/diagnostics@2.0.3': resolution: {integrity: sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==} - '@definitelytyped/header-parser@0.2.16': - resolution: {integrity: sha512-UFsgPft5bhZn07UNGz/9ck4AhdKgLFEOmi2DNr7gXcGL89zbe3u5oVafKUT8j1HOtSBjT8ZEQsXHKlbq+wwF/Q==} + '@definitelytyped/header-parser@0.2.17': + resolution: {integrity: sha512-U0juKFkTOcbkSfO83WSzMEJHYDwoBFiq0tf/JszulL3+7UoSiqunpGmxXS54bm3eGqy7GWjV8AqPQHdeoEaWBQ==} engines: {node: '>=18.18.0'} - '@definitelytyped/typescript-versions@0.1.6': - resolution: {integrity: sha512-gQpXFteIKrOw4ldmBZQfBrD3WobaIG1SwOr/3alXWkcYbkOWa2NRxQbiaYQ2IvYTGaZK26miJw0UOAFiuIs4gA==} + '@definitelytyped/typescript-versions@0.1.7': + resolution: {integrity: sha512-sBzBi1SBn79OkSr8V0H+FzR7QumHk23syPyRxod/VRBrSkgN9rCliIe+nqLoWRAKN8EeKbp00ketnJNLZhucdA==} engines: {node: '>=18.18.0'} '@definitelytyped/utils@0.1.8': @@ -29973,13 +29970,13 @@ snapshots: enabled: 2.0.0 kuler: 2.0.0 - '@definitelytyped/header-parser@0.2.16': + '@definitelytyped/header-parser@0.2.17': dependencies: - '@definitelytyped/typescript-versions': 0.1.6 + '@definitelytyped/typescript-versions': 0.1.7 '@definitelytyped/utils': 0.1.8 semver: 7.6.3 - '@definitelytyped/typescript-versions@0.1.6': {} + '@definitelytyped/typescript-versions@0.1.7': {} '@definitelytyped/utils@0.1.8': dependencies: @@ -32274,6 +32271,8 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) + transitivePeerDependencies: + - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: @@ -36654,7 +36653,7 @@ snapshots: dts-critic@3.3.11(typescript@5.7.2): dependencies: - '@definitelytyped/header-parser': 0.2.16 + '@definitelytyped/header-parser': 0.2.17 command-exists: 1.2.9 rimraf: 3.0.2 semver: 6.3.1 @@ -36664,8 +36663,8 @@ snapshots: dtslint@4.2.1(typescript@5.7.2): dependencies: - '@definitelytyped/header-parser': 0.2.16 - '@definitelytyped/typescript-versions': 0.1.6 + '@definitelytyped/header-parser': 0.2.17 + '@definitelytyped/typescript-versions': 0.1.7 '@definitelytyped/utils': 0.1.8 dts-critic: 3.3.11(typescript@5.7.2) fs-extra: 6.0.1