From c459454ef86f8851ca636ff11f9c404587a16bf7 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Fri, 4 Apr 2025 11:23:57 -0400 Subject: [PATCH 1/7] new components --- .../actions/compress-pdf/compress-pdf.mjs | 64 +++++++++++++++++++ .../actions/convert-to-pdf/convert-to-pdf.mjs | 47 ++++++++++++++ .../pdf4me/actions/merge-pdfs/merge-pdfs.mjs | 46 +++++++++++++ components/pdf4me/common/utils.mjs | 31 +++++++++ components/pdf4me/package.json | 7 +- components/pdf4me/pdf4me.app.mjs | 56 ++++++++++++++-- 6 files changed, 244 insertions(+), 7 deletions(-) create mode 100644 components/pdf4me/actions/compress-pdf/compress-pdf.mjs create mode 100644 components/pdf4me/actions/convert-to-pdf/convert-to-pdf.mjs create mode 100644 components/pdf4me/actions/merge-pdfs/merge-pdfs.mjs create mode 100644 components/pdf4me/common/utils.mjs diff --git a/components/pdf4me/actions/compress-pdf/compress-pdf.mjs b/components/pdf4me/actions/compress-pdf/compress-pdf.mjs new file mode 100644 index 0000000000000..5a799ebdeced9 --- /dev/null +++ b/components/pdf4me/actions/compress-pdf/compress-pdf.mjs @@ -0,0 +1,64 @@ +import pdf4me from "../../pdf4me.app.mjs"; +import utils from "../../common/utils.mjs"; +import fs from "fs"; + +export default { + key: "pdf4me-compress-pdf", + name: "Compress PDF", + description: "Compress a PDF file to reduce its size. [See the documentation](https://dev.pdf4me.com/apiv2/documentation/actions/compress-pdf/)", + version: "0.0.1", + type: "action", + props: { + pdf4me, + filePath: { + propDefinition: [ + pdf4me, + "filePath,", + ], + }, + optimizeProfile: { + type: "string", + label: "Optimize Profile", + description: "The type of compression", + options: [ + "Max", + "Web", + "Print", + "Default", + "WebMax", + "PrintMax", + "PrintGray", + "Compress", + "CompressMax", + ], + }, + filename: { + propDefinition: [ + pdf4me, + "filename", + ], + }, + }, + async run({ $ }) { + const filename = utils.checkForExtension(this.filename, "pdf"); + const filePath = utils.normalizeFilePath(this.filePath); + const fileContent = fs.readFileSync(filePath, { + encoding: "base64", + }); + + const response = await this.pdf4me.compressPdf({ + $, + data: { + docContent: fileContent, + docName: filename, + optimizeProfile: this.optimizeProfile, + }, + responseType: "arraybuffer", + }); + + const filedata = utils.downloadToTmp(response, filename); + + $.export("$summary", "Successfully compressed PDF file"); + return filedata; + }, +}; diff --git a/components/pdf4me/actions/convert-to-pdf/convert-to-pdf.mjs b/components/pdf4me/actions/convert-to-pdf/convert-to-pdf.mjs new file mode 100644 index 0000000000000..cf87f9f9f1144 --- /dev/null +++ b/components/pdf4me/actions/convert-to-pdf/convert-to-pdf.mjs @@ -0,0 +1,47 @@ +import pdf4me from "../../pdf4me.app.mjs"; +import utils from "../../common/utils.mjs"; +import fs from "fs"; + +export default { + key: "pdf4me-convert-to-pdf", + name: "Convert to PDF", + description: "Convert a document (e.g., DOCX, XLSX, PPTX) to PDF. [See the documentation](https://dev.pdf4me.com/apiv2/documentation/actions/convert-to-pdf/)", + version: "0.0.1", + type: "action", + props: { + pdf4me, + filePath: { + propDefinition: [ + pdf4me, + "filePath", + ], + description: "The path to a DOCX, XLSX, or PPTX file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)", + }, + filename: { + propDefinition: [ + pdf4me, + "filename", + ], + }, + }, + async run({ $ }) { + const filePath = utils.normalizeFilePath(this.filePath); + const fileContent = fs.readFileSync(filePath, { + encoding: "base64", + }); + + const response = await this.pdf4me.convertToPdf({ + $, + data: { + docContent: fileContent, + docName: this.filename, + }, + responseType: "arraybuffer", + }); + + const filedata = utils.downloadToTmp(response, this.filename); + + $.export("$summary", "Successfully converted file to PDF"); + return filedata; + }, +}; diff --git a/components/pdf4me/actions/merge-pdfs/merge-pdfs.mjs b/components/pdf4me/actions/merge-pdfs/merge-pdfs.mjs new file mode 100644 index 0000000000000..df5857656831d --- /dev/null +++ b/components/pdf4me/actions/merge-pdfs/merge-pdfs.mjs @@ -0,0 +1,46 @@ +import pdf4me from "../../pdf4me.app.mjs"; +import utils from "../../common/utils.mjs"; +import fs from "fs"; + +export default { + key: "pdf4me-merge-pdfs", + name: "Merge PDF Files", + description: "Merge multiple PDF files into a single PDF. [See the documentation](https://dev.pdf4me.com/apiv2/documentation/actions/merge/)", + version: "0.0.1", + type: "action", + props: { + pdf4me, + filePaths: { + type: "string[]", + label: "File Paths", + description: "An array of paths to a PDF files in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)", + }, + filename: { + propDefinition: [ + pdf4me, + "filename", + ], + }, + }, + async run({ $ }) { + const filename = utils.checkForExtension(this.filename, "pdf"); + const filePaths = this.filePaths.map((path) => utils.normalizeFilePath(path)); + const fileContents = filePaths.map((path) => fs.readFileSync(path, { + encoding: "base64", + })); + + const response = await this.pdf4me.mergePdfs({ + $, + data: { + docContent: fileContents, + docName: filename, + }, + responseType: "arraybuffer", + }); + + const filedata = utils.downloadToTmp(response, filename); + + $.export("$summary", "Successfully merged PDF files"); + return filedata; + }, +}; diff --git a/components/pdf4me/common/utils.mjs b/components/pdf4me/common/utils.mjs new file mode 100644 index 0000000000000..531a61e891c30 --- /dev/null +++ b/components/pdf4me/common/utils.mjs @@ -0,0 +1,31 @@ +import fs from "fs"; + +function normalizeFilePath(path) { + return path.includes("tmp/") + ? path + : `/tmp/${path}`; +} + +function checkForExtension(filename, ext = "pdf") { + return filename.includes(`.${ext}`) + ? filename + : `${filename}.${ext}`; +} + +function downloadToTmp(response, filename) { + const rawcontent = response.toString("base64"); + const buffer = Buffer.from(rawcontent, "base64"); + const filePath = normalizeFilePath(filename); + fs.writeFileSync(filePath, buffer); + + return [ + filename, + filePath, + ]; +} + +export default { + normalizeFilePath, + checkForExtension, + downloadToTmp, +}; diff --git a/components/pdf4me/package.json b/components/pdf4me/package.json index 9a61f0283dc86..ba088f91d5b82 100644 --- a/components/pdf4me/package.json +++ b/components/pdf4me/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/pdf4me", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream PDF4me Components", "main": "pdf4me.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/pdf4me/pdf4me.app.mjs b/components/pdf4me/pdf4me.app.mjs index 22217d81d7030..4b9c5d178b261 100644 --- a/components/pdf4me/pdf4me.app.mjs +++ b/components/pdf4me/pdf4me.app.mjs @@ -1,11 +1,57 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "pdf4me", - propDefinitions: {}, + propDefinitions: { + filePath: { + type: "string", + label: "File Path", + description: "The path to a PDF file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)", + }, + filename: { + type: "string", + label: "File Name", + description: "The filename to save the resulting PDF in the /tmp directory", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.pdf4me.com/api/v2"; + }, + _makeRequest({ + $ = this, + path = "/", + ...otherOpts + }) { + return axios($, { + ...otherOpts, + url: `${this._baseUrl()}${path}`, + headers: { + authorization: this.$auth.api_key, + }, + }); + }, + convertToPdf(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/ConvertToPdf", + ...opts, + }); + }, + mergePdfs(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/Merge", + ...opts, + }); + }, + compressPdf(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/Optimize", + ...opts, + }); }, }, -}; \ No newline at end of file +}; From f92034529b027f337490049e1ceeb87f5a5af533 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Fri, 4 Apr 2025 11:30:14 -0400 Subject: [PATCH 2/7] pnpm-lock.yaml --- pnpm-lock.yaml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a894ef0641a79..0a6a5e5c3253e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9306,7 +9306,11 @@ importers: specifier: ^2.0.0 version: 2.0.0 - components/pdf4me: {} + components/pdf4me: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/pdf_api_io: {} @@ -16462,8 +16466,8 @@ packages: '@dabh/diagnostics@2.0.3': resolution: {integrity: sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==} - '@definitelytyped/header-parser@0.2.18': - resolution: {integrity: sha512-3JWGzhieGOx+zhy+qaPDoiby2TPA1PZGpEJHt0VwR1aK0R9dER5BoBvnT5zSafg9kHQTw4aBRFbt3o41FNkaLw==} + '@definitelytyped/header-parser@0.2.19': + resolution: {integrity: sha512-zu+RxQpUCgorYUQZoyyrRIn9CljL1CeM4qak3NDeMO1r7tjAkodfpAGnVzx/6JR2OUk0tAgwmZxNMSwd9LVgxw==} engines: {node: '>=18.18.0'} '@definitelytyped/typescript-versions@0.1.8': @@ -32205,7 +32209,7 @@ snapshots: enabled: 2.0.0 kuler: 2.0.0 - '@definitelytyped/header-parser@0.2.18': + '@definitelytyped/header-parser@0.2.19': dependencies: '@definitelytyped/typescript-versions': 0.1.8 '@definitelytyped/utils': 0.1.8 @@ -38845,7 +38849,7 @@ snapshots: dts-critic@3.3.11(typescript@5.7.2): dependencies: - '@definitelytyped/header-parser': 0.2.18 + '@definitelytyped/header-parser': 0.2.19 command-exists: 1.2.9 rimraf: 3.0.2 semver: 6.3.1 @@ -38855,7 +38859,7 @@ snapshots: dtslint@4.2.1(typescript@5.7.2): dependencies: - '@definitelytyped/header-parser': 0.2.18 + '@definitelytyped/header-parser': 0.2.19 '@definitelytyped/typescript-versions': 0.1.8 '@definitelytyped/utils': 0.1.8 dts-critic: 3.3.11(typescript@5.7.2) From 1f2a7a5d841fdec559464e865350956bfaf9836d Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Fri, 4 Apr 2025 11:42:31 -0400 Subject: [PATCH 3/7] fix prop --- components/pdf4me/actions/compress-pdf/compress-pdf.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/pdf4me/actions/compress-pdf/compress-pdf.mjs b/components/pdf4me/actions/compress-pdf/compress-pdf.mjs index 5a799ebdeced9..7f259e3fc19f6 100644 --- a/components/pdf4me/actions/compress-pdf/compress-pdf.mjs +++ b/components/pdf4me/actions/compress-pdf/compress-pdf.mjs @@ -13,7 +13,7 @@ export default { filePath: { propDefinition: [ pdf4me, - "filePath,", + "filePath", ], }, optimizeProfile: { From a96e0842bc33602f3eb14ae452e1a67ab6dae684 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Fri, 4 Apr 2025 12:24:17 -0400 Subject: [PATCH 4/7] Update components/pdf4me/common/utils.mjs Co-authored-by: Jorge Cortes --- components/pdf4me/common/utils.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/pdf4me/common/utils.mjs b/components/pdf4me/common/utils.mjs index 531a61e891c30..b697f09ab168b 100644 --- a/components/pdf4me/common/utils.mjs +++ b/components/pdf4me/common/utils.mjs @@ -1,7 +1,7 @@ import fs from "fs"; function normalizeFilePath(path) { - return path.includes("tmp/") + return path.startsWith("/tmp/") ? path : `/tmp/${path}`; } From d3a631605bffaf460687846532cd45d567f887ca Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 7 Apr 2025 13:54:44 -0400 Subject: [PATCH 5/7] error handling --- components/pdf4me/common/utils.mjs | 15 +++++++++++++++ components/pdf4me/pdf4me.app.mjs | 21 +++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/components/pdf4me/common/utils.mjs b/components/pdf4me/common/utils.mjs index b697f09ab168b..9dbac47370a2b 100644 --- a/components/pdf4me/common/utils.mjs +++ b/components/pdf4me/common/utils.mjs @@ -1,4 +1,5 @@ import fs from "fs"; +import { ConfigurationError } from "@pipedream/platform"; function normalizeFilePath(path) { return path.startsWith("/tmp/") @@ -24,8 +25,22 @@ function downloadToTmp(response, filename) { ]; } +function handleErrorMessage(error) { + let errorMessage = error.name; + if (error.response && error.response.data) { + const text = Buffer.from(error.response.data).toString("utf-8"); + try { + errorMessage = JSON.stringify(JSON.parse(text)); + } catch (parseErr) { + errorMessage = text; + } + } + throw new ConfigurationError(`${errorMessage}`); +} + export default { normalizeFilePath, checkForExtension, downloadToTmp, + handleErrorMessage, }; diff --git a/components/pdf4me/pdf4me.app.mjs b/components/pdf4me/pdf4me.app.mjs index 4b9c5d178b261..ec179a9ff9730 100644 --- a/components/pdf4me/pdf4me.app.mjs +++ b/components/pdf4me/pdf4me.app.mjs @@ -1,4 +1,5 @@ import { axios } from "@pipedream/platform"; +import utils from "./common/utils.mjs"; export default { type: "app", @@ -19,18 +20,22 @@ export default { _baseUrl() { return "https://api.pdf4me.com/api/v2"; }, - _makeRequest({ + async _makeRequest({ $ = this, path = "/", ...otherOpts }) { - return axios($, { - ...otherOpts, - url: `${this._baseUrl()}${path}`, - headers: { - authorization: this.$auth.api_key, - }, - }); + try { + return await axios($, { + ...otherOpts, + url: `${this._baseUrl()}${path}`, + headers: { + authorization: this.$auth.api_key, + }, + }); + } catch (error) { + utils.handleErrorMessage(error); + } }, convertToPdf(opts = {}) { return this._makeRequest({ From 22a07d59cefcb6d84489012ceb8c6afaee4f71ac Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 7 Apr 2025 14:00:38 -0400 Subject: [PATCH 6/7] pnpm-lock.yaml --- pnpm-lock.yaml | 218 ++++++++----------------------------------------- 1 file changed, 34 insertions(+), 184 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4bc9af842e9dd..62dd4a6681343 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -379,8 +379,7 @@ importers: specifier: ^20.0.0 version: 20.0.0 - components/adyntel: - specifiers: {} + components/adyntel: {} components/aerisweather: dependencies: @@ -14899,8 +14898,8 @@ importers: docs-v2: dependencies: '@docsearch/react': - specifier: ^3.6.1 - version: 3.8.0(@algolia/client-search@5.17.1)(@types/react@18.3.12)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.3) + specifier: ^3.8.1 + version: 3.9.0(@algolia/client-search@5.17.1)(@types/react@18.3.12)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.3) '@vercel/analytics': specifier: ^1.3.1 version: 1.4.1(next@14.2.19(@babel/core@8.0.0-alpha.13)(@opentelemetry/api@1.9.0)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)(vue@2.7.16) @@ -15195,126 +15194,74 @@ packages: resolution: {integrity: sha512-C+jj5XBTCNs7AFwufOkPLhuqn9bdgSDcqLB6b/Ppi9Fujwt613vWmA1hxeG76RX49vzHZIDJLq6N/v0o2SY1sA==} engines: {node: '>=18'} - '@algolia/autocomplete-core@1.17.7': - resolution: {integrity: sha512-BjiPOW6ks90UKl7TwMv7oNQMnzU+t/wk9mgIDi6b1tXpUek7MW0lbNOUHpvam9pe3lVCf4xPFT+lK7s+e+fs7Q==} + '@algolia/autocomplete-core@1.17.9': + resolution: {integrity: sha512-O7BxrpLDPJWWHv/DLA9DRFWs+iY1uOJZkqUwjS5HSZAGcl0hIVCQ97LTLewiZmZ402JYUrun+8NqFP+hCknlbQ==} - '@algolia/autocomplete-plugin-algolia-insights@1.17.7': - resolution: {integrity: sha512-Jca5Ude6yUOuyzjnz57og7Et3aXjbwCSDf/8onLHSQgw1qW3ALl9mrMWaXb5FmPVkV3EtkD2F/+NkT6VHyPu9A==} + '@algolia/autocomplete-plugin-algolia-insights@1.17.9': + resolution: {integrity: sha512-u1fEHkCbWF92DBeB/KHeMacsjsoI0wFhjZtlCq2ddZbAehshbZST6Hs0Avkc0s+4UyBGbMDnSuXHLuvRWK5iDQ==} peerDependencies: search-insights: '>= 1 < 3' - '@algolia/autocomplete-preset-algolia@1.17.7': - resolution: {integrity: sha512-ggOQ950+nwbWROq2MOCIL71RE0DdQZsceqrg32UqnhDz8FlO9rL8ONHNsI2R1MH0tkgVIDKI/D0sMiUchsFdWA==} + '@algolia/autocomplete-preset-algolia@1.17.9': + resolution: {integrity: sha512-Na1OuceSJeg8j7ZWn5ssMu/Ax3amtOwk76u4h5J4eK2Nx2KB5qt0Z4cOapCsxot9VcEN11ADV5aUSlQF4RhGjQ==} peerDependencies: '@algolia/client-search': '>= 4.9.1 < 6' algoliasearch: '>= 4.9.1 < 6' - '@algolia/autocomplete-shared@1.17.7': - resolution: {integrity: sha512-o/1Vurr42U/qskRSuhBH+VKxMvkkUVTLU6WZQr+L5lGZZLYWyhdzWjW0iGXY7EkwRTjBqvN2EsR81yCTGV/kmg==} + '@algolia/autocomplete-shared@1.17.9': + resolution: {integrity: sha512-iDf05JDQ7I0b7JEA/9IektxN/80a2MZ1ToohfmNS3rfeuQnIKI3IJlIafD0xu4StbtQTghx9T3Maa97ytkXenQ==} peerDependencies: '@algolia/client-search': '>= 4.9.1 < 6' algoliasearch: '>= 4.9.1 < 6' - '@algolia/client-abtesting@5.15.0': - resolution: {integrity: sha512-FaEM40iuiv1mAipYyiptP4EyxkJ8qHfowCpEeusdHUC4C7spATJYArD2rX3AxkVeREkDIgYEOuXcwKUbDCr7Nw==} - engines: {node: '>= 14.0.0'} - '@algolia/client-abtesting@5.17.1': resolution: {integrity: sha512-Os/xkQbDp5A5RdGYq1yS3fF69GoBJH5FIfrkVh+fXxCSe714i1Xdl9XoXhS4xG76DGKm6EFMlUqP024qjps8cg==} engines: {node: '>= 14.0.0'} - '@algolia/client-analytics@5.15.0': - resolution: {integrity: sha512-lho0gTFsQDIdCwyUKTtMuf9nCLwq9jOGlLGIeQGKDxXF7HbiAysFIu5QW/iQr1LzMgDyM9NH7K98KY+BiIFriQ==} - engines: {node: '>= 14.0.0'} - '@algolia/client-analytics@5.17.1': resolution: {integrity: sha512-WKpGC+cUhmdm3wndIlTh8RJXoVabUH+4HrvZHC4hXtvCYojEXYeep8RZstatwSZ7Ocg6Y2u67bLw90NEINuYEw==} engines: {node: '>= 14.0.0'} - '@algolia/client-common@5.15.0': - resolution: {integrity: sha512-IofrVh213VLsDkPoSKMeM9Dshrv28jhDlBDLRcVJQvlL8pzue7PEB1EZ4UoJFYS3NSn7JOcJ/V+olRQzXlJj1w==} - engines: {node: '>= 14.0.0'} - '@algolia/client-common@5.17.1': resolution: {integrity: sha512-5rb5+yPIie6912riAypTSyzbE23a7UM1UpESvD8GEPI4CcWQvA9DBlkRNx9qbq/nJ5pvv8VjZjUxJj7rFkzEAA==} engines: {node: '>= 14.0.0'} - '@algolia/client-insights@5.15.0': - resolution: {integrity: sha512-bDDEQGfFidDi0UQUCbxXOCdphbVAgbVmxvaV75cypBTQkJ+ABx/Npw7LkFGw1FsoVrttlrrQbwjvUB6mLVKs/w==} - engines: {node: '>= 14.0.0'} - '@algolia/client-insights@5.17.1': resolution: {integrity: sha512-nb/tfwBMn209TzFv1DDTprBKt/wl5btHVKoAww9fdEVdoKK02R2KAqxe5tuXLdEzAsS+LevRyOM/YjXuLmPtjQ==} engines: {node: '>= 14.0.0'} - '@algolia/client-personalization@5.15.0': - resolution: {integrity: sha512-LfaZqLUWxdYFq44QrasCDED5bSYOswpQjSiIL7Q5fYlefAAUO95PzBPKCfUhSwhb4rKxigHfDkd81AvEicIEoA==} - engines: {node: '>= 14.0.0'} - '@algolia/client-personalization@5.17.1': resolution: {integrity: sha512-JuNlZe1SdW9KbV0gcgdsiVkFfXt0mmPassdS3cBSGvZGbPB9JsHthD719k5Y6YOY4dGvw1JmC1i9CwCQHAS8hg==} engines: {node: '>= 14.0.0'} - '@algolia/client-query-suggestions@5.15.0': - resolution: {integrity: sha512-wu8GVluiZ5+il8WIRsGKu8VxMK9dAlr225h878GGtpTL6VBvwyJvAyLdZsfFIpY0iN++jiNb31q2C1PlPL+n/A==} - engines: {node: '>= 14.0.0'} - '@algolia/client-query-suggestions@5.17.1': resolution: {integrity: sha512-RBIFIv1QE3IlAikJKWTOpd6pwE4d2dY6t02iXH7r/SLXWn0HzJtsAPPeFg/OKkFvWAXt0H7In2/Mp7a1/Dy2pw==} engines: {node: '>= 14.0.0'} - '@algolia/client-search@5.15.0': - resolution: {integrity: sha512-Z32gEMrRRpEta5UqVQA612sLdoqY3AovvUPClDfMxYrbdDAebmGDVPtSogUba1FZ4pP5dx20D3OV3reogLKsRA==} - engines: {node: '>= 14.0.0'} - '@algolia/client-search@5.17.1': resolution: {integrity: sha512-bd5JBUOP71kPsxwDcvOxqtqXXVo/706NFifZ/O5Rx5GB8ZNVAhg4l7aGoT6jBvEfgmrp2fqPbkdIZ6JnuOpGcw==} engines: {node: '>= 14.0.0'} - '@algolia/ingestion@1.15.0': - resolution: {integrity: sha512-MkqkAxBQxtQ5if/EX2IPqFA7LothghVyvPoRNA/meS2AW2qkHwcxjuiBxv4H6mnAVEPfJlhu9rkdVz9LgCBgJg==} - engines: {node: '>= 14.0.0'} - '@algolia/ingestion@1.17.1': resolution: {integrity: sha512-T18tvePi1rjRYcIKhd82oRukrPWHxG/Iy1qFGaxCplgRm9Im5z96qnYOq75MSKGOUHkFxaBKJOLmtn8xDR+Mcw==} engines: {node: '>= 14.0.0'} - '@algolia/monitoring@1.15.0': - resolution: {integrity: sha512-QPrFnnGLMMdRa8t/4bs7XilPYnoUXDY8PMQJ1sf9ZFwhUysYYhQNX34/enoO0LBjpoOY6rLpha39YQEFbzgKyQ==} - engines: {node: '>= 14.0.0'} - '@algolia/monitoring@1.17.1': resolution: {integrity: sha512-gDtow+AUywTehRP8S1tWKx2IvhcJOxldAoqBxzN3asuQobF7er5n72auBeL++HY4ImEuzMi7PDOA/Iuwxs2IcA==} engines: {node: '>= 14.0.0'} - '@algolia/recommend@5.15.0': - resolution: {integrity: sha512-5eupMwSqMLDObgSMF0XG958zR6GJP3f7jHDQ3/WlzCM9/YIJiWIUoJFGsko9GYsA5xbLDHE/PhWtq4chcCdaGQ==} - engines: {node: '>= 14.0.0'} - '@algolia/recommend@5.17.1': resolution: {integrity: sha512-2992tTHkRe18qmf5SP57N78kN1D3e5t4PO1rt10sJncWtXBZWiNOK6K/UcvWsFbNSGAogFcIcvIMAl5mNp6RWA==} engines: {node: '>= 14.0.0'} - '@algolia/requester-browser-xhr@5.15.0': - resolution: {integrity: sha512-Po/GNib6QKruC3XE+WKP1HwVSfCDaZcXu48kD+gwmtDlqHWKc7Bq9lrS0sNZ456rfCKhXksOmMfUs4wRM/Y96w==} - engines: {node: '>= 14.0.0'} - '@algolia/requester-browser-xhr@5.17.1': resolution: {integrity: sha512-XpKgBfyczVesKgr7DOShNyPPu5kqlboimRRPjdqAw5grSyHhCmb8yoTIKy0TCqBABZeXRPMYT13SMruUVRXvHA==} engines: {node: '>= 14.0.0'} - '@algolia/requester-fetch@5.15.0': - resolution: {integrity: sha512-rOZ+c0P7ajmccAvpeeNrUmEKoliYFL8aOR5qGW5pFq3oj3Iept7Y5mEtEsOBYsRt6qLnaXn4zUKf+N8nvJpcIw==} - engines: {node: '>= 14.0.0'} - '@algolia/requester-fetch@5.17.1': resolution: {integrity: sha512-EhUomH+DZP5vb6DnEjT0GvXaXBSwzZnuU6hPGNU1EYKRXDouRjII/bIWpVjt7ycMgL2D2oQruqDh6rAWUhQwRw==} engines: {node: '>= 14.0.0'} - '@algolia/requester-node-http@5.15.0': - resolution: {integrity: sha512-b1jTpbFf9LnQHEJP5ddDJKE2sAlhYd7EVSOWgzo/27n/SfCoHfqD0VWntnWYD83PnOKvfe8auZ2+xCb0TXotrQ==} - engines: {node: '>= 14.0.0'} - '@algolia/requester-node-http@5.17.1': resolution: {integrity: sha512-PSnENJtl4/wBWXlGyOODbLYm6lSiFqrtww7UpQRCJdsHXlJKF8XAP6AME8NxvbE0Qo/RJUxK0mvyEh9sQcx6bg==} engines: {node: '>= 14.0.0'} @@ -16484,15 +16431,15 @@ packages: resolution: {integrity: sha512-4JINx4Rttha29f50PBsJo48xZXx/He5yaIWJRwVarhYAN947+S84YciHl+AIhQNRPAFkg8+5qFngEGtKxQDWXA==} engines: {node: '>=18.18.0'} - '@docsearch/css@3.8.0': - resolution: {integrity: sha512-pieeipSOW4sQ0+bE5UFC51AOZp9NGxg89wAlZ1BAQFaiRAGK1IKUaPQ0UGZeNctJXyqZ1UvBtOQh2HH+U5GtmA==} + '@docsearch/css@3.9.0': + resolution: {integrity: sha512-cQbnVbq0rrBwNAKegIac/t6a8nWoUAn8frnkLFW6YARaRmAQr5/Eoe6Ln2fqkUCZ40KpdrKbpSAmgrkviOxuWA==} - '@docsearch/react@3.8.0': - resolution: {integrity: sha512-WnFK720+iwTVt94CxY3u+FgX6exb3BfN5kE9xUY6uuAH/9W/UFboBZFLlrw/zxFRHoHZCOXRtOylsXF+6LHI+Q==} + '@docsearch/react@3.9.0': + resolution: {integrity: sha512-mb5FOZYZIkRQ6s/NWnM98k879vu5pscWqTLubLFBO87igYYT4VzVazh4h5o/zCvTIZgEt3PvsCOMOswOUo9yHQ==} peerDependencies: - '@types/react': '>= 16.8.0 < 19.0.0' - react: '>= 16.8.0 < 19.0.0' - react-dom: '>= 16.8.0 < 19.0.0' + '@types/react': '>= 16.8.0 < 20.0.0' + react: '>= 16.8.0 < 20.0.0' + react-dom: '>= 16.8.0 < 20.0.0' search-insights: '>= 1 < 3' peerDependenciesMeta: '@types/react': @@ -20235,10 +20182,6 @@ packages: ajv@8.17.1: resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} - algoliasearch@5.15.0: - resolution: {integrity: sha512-Yf3Swz1s63hjvBVZ/9f2P1Uu48GjmjCN+Esxb6MAONMGtZB1fRX8/S1AhUTtsuTlcGovbYLxpHgc7wEzstDZBw==} - engines: {node: '>= 14.0.0'} - algoliasearch@5.17.1: resolution: {integrity: sha512-3CcbT5yTWJDIcBe9ZHgsPi184SkT1kyZi3GWlQU5EFgvq1V73X2sqHRkPCQMe0RA/uvZbB+1sFeAk73eWygeLg==} engines: {node: '>= 14.0.0'} @@ -29123,40 +29066,33 @@ snapshots: transitivePeerDependencies: - supports-color - '@algolia/autocomplete-core@1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0)(search-insights@2.17.3)': + '@algolia/autocomplete-core@1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1)(search-insights@2.17.3)': dependencies: - '@algolia/autocomplete-plugin-algolia-insights': 1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0)(search-insights@2.17.3) - '@algolia/autocomplete-shared': 1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0) + '@algolia/autocomplete-plugin-algolia-insights': 1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1)(search-insights@2.17.3) + '@algolia/autocomplete-shared': 1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1) transitivePeerDependencies: - '@algolia/client-search' - algoliasearch - search-insights - '@algolia/autocomplete-plugin-algolia-insights@1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0)(search-insights@2.17.3)': + '@algolia/autocomplete-plugin-algolia-insights@1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1)(search-insights@2.17.3)': dependencies: - '@algolia/autocomplete-shared': 1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0) + '@algolia/autocomplete-shared': 1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1) search-insights: 2.17.3 transitivePeerDependencies: - '@algolia/client-search' - algoliasearch - '@algolia/autocomplete-preset-algolia@1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0)': + '@algolia/autocomplete-preset-algolia@1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1)': dependencies: - '@algolia/autocomplete-shared': 1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0) + '@algolia/autocomplete-shared': 1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1) '@algolia/client-search': 5.17.1 - algoliasearch: 5.15.0 + algoliasearch: 5.17.1 - '@algolia/autocomplete-shared@1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0)': + '@algolia/autocomplete-shared@1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1)': dependencies: '@algolia/client-search': 5.17.1 - algoliasearch: 5.15.0 - - '@algolia/client-abtesting@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 + algoliasearch: 5.17.1 '@algolia/client-abtesting@5.17.1': dependencies: @@ -29165,13 +29101,6 @@ snapshots: '@algolia/requester-fetch': 5.17.1 '@algolia/requester-node-http': 5.17.1 - '@algolia/client-analytics@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 - '@algolia/client-analytics@5.17.1': dependencies: '@algolia/client-common': 5.17.1 @@ -29179,17 +29108,8 @@ snapshots: '@algolia/requester-fetch': 5.17.1 '@algolia/requester-node-http': 5.17.1 - '@algolia/client-common@5.15.0': {} - '@algolia/client-common@5.17.1': {} - '@algolia/client-insights@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 - '@algolia/client-insights@5.17.1': dependencies: '@algolia/client-common': 5.17.1 @@ -29197,13 +29117,6 @@ snapshots: '@algolia/requester-fetch': 5.17.1 '@algolia/requester-node-http': 5.17.1 - '@algolia/client-personalization@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 - '@algolia/client-personalization@5.17.1': dependencies: '@algolia/client-common': 5.17.1 @@ -29211,13 +29124,6 @@ snapshots: '@algolia/requester-fetch': 5.17.1 '@algolia/requester-node-http': 5.17.1 - '@algolia/client-query-suggestions@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 - '@algolia/client-query-suggestions@5.17.1': dependencies: '@algolia/client-common': 5.17.1 @@ -29225,13 +29131,6 @@ snapshots: '@algolia/requester-fetch': 5.17.1 '@algolia/requester-node-http': 5.17.1 - '@algolia/client-search@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 - '@algolia/client-search@5.17.1': dependencies: '@algolia/client-common': 5.17.1 @@ -29239,13 +29138,6 @@ snapshots: '@algolia/requester-fetch': 5.17.1 '@algolia/requester-node-http': 5.17.1 - '@algolia/ingestion@1.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 - '@algolia/ingestion@1.17.1': dependencies: '@algolia/client-common': 5.17.1 @@ -29253,13 +29145,6 @@ snapshots: '@algolia/requester-fetch': 5.17.1 '@algolia/requester-node-http': 5.17.1 - '@algolia/monitoring@1.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 - '@algolia/monitoring@1.17.1': dependencies: '@algolia/client-common': 5.17.1 @@ -29267,13 +29152,6 @@ snapshots: '@algolia/requester-fetch': 5.17.1 '@algolia/requester-node-http': 5.17.1 - '@algolia/recommend@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 - '@algolia/recommend@5.17.1': dependencies: '@algolia/client-common': 5.17.1 @@ -29281,26 +29159,14 @@ snapshots: '@algolia/requester-fetch': 5.17.1 '@algolia/requester-node-http': 5.17.1 - '@algolia/requester-browser-xhr@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-browser-xhr@5.17.1': dependencies: '@algolia/client-common': 5.17.1 - '@algolia/requester-fetch@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-fetch@5.17.1': dependencies: '@algolia/client-common': 5.17.1 - '@algolia/requester-node-http@5.15.0': - dependencies: - '@algolia/client-common': 5.15.0 - '@algolia/requester-node-http@5.17.1': dependencies: '@algolia/client-common': 5.17.1 @@ -32234,14 +32100,14 @@ snapshots: tar-stream: 3.1.7 which: 4.0.0 - '@docsearch/css@3.8.0': {} + '@docsearch/css@3.9.0': {} - '@docsearch/react@3.8.0(@algolia/client-search@5.17.1)(@types/react@18.3.12)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.3)': + '@docsearch/react@3.9.0(@algolia/client-search@5.17.1)(@types/react@18.3.12)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(search-insights@2.17.3)': dependencies: - '@algolia/autocomplete-core': 1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0)(search-insights@2.17.3) - '@algolia/autocomplete-preset-algolia': 1.17.7(@algolia/client-search@5.17.1)(algoliasearch@5.15.0) - '@docsearch/css': 3.8.0 - algoliasearch: 5.15.0 + '@algolia/autocomplete-core': 1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1)(search-insights@2.17.3) + '@algolia/autocomplete-preset-algolia': 1.17.9(@algolia/client-search@5.17.1)(algoliasearch@5.17.1) + '@docsearch/css': 3.9.0 + algoliasearch: 5.17.1 optionalDependencies: '@types/react': 18.3.12 react: 18.3.1 @@ -36843,22 +36709,6 @@ snapshots: json-schema-traverse: 1.0.0 require-from-string: 2.0.2 - algoliasearch@5.15.0: - dependencies: - '@algolia/client-abtesting': 5.15.0 - '@algolia/client-analytics': 5.15.0 - '@algolia/client-common': 5.15.0 - '@algolia/client-insights': 5.15.0 - '@algolia/client-personalization': 5.15.0 - '@algolia/client-query-suggestions': 5.15.0 - '@algolia/client-search': 5.15.0 - '@algolia/ingestion': 1.15.0 - '@algolia/monitoring': 1.15.0 - '@algolia/recommend': 5.15.0 - '@algolia/requester-browser-xhr': 5.15.0 - '@algolia/requester-fetch': 5.15.0 - '@algolia/requester-node-http': 5.15.0 - algoliasearch@5.17.1: dependencies: '@algolia/client-abtesting': 5.17.1 From bd501eb75392d29969be934825580e5d4e75f2c6 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 7 Apr 2025 14:06:05 -0400 Subject: [PATCH 7/7] updates --- components/pdf4me/common/utils.mjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/pdf4me/common/utils.mjs b/components/pdf4me/common/utils.mjs index 9dbac47370a2b..6f46d4edf4569 100644 --- a/components/pdf4me/common/utils.mjs +++ b/components/pdf4me/common/utils.mjs @@ -8,7 +8,7 @@ function normalizeFilePath(path) { } function checkForExtension(filename, ext = "pdf") { - return filename.includes(`.${ext}`) + return filename.endsWith(`.${ext}`) ? filename : `${filename}.${ext}`; } @@ -26,8 +26,11 @@ function downloadToTmp(response, filename) { } function handleErrorMessage(error) { + if (!error) { + throw new ConfigurationError("Unknown error occurred"); + } let errorMessage = error.name; - if (error.response && error.response.data) { + if (error.response?.data) { const text = Buffer.from(error.response.data).toString("utf-8"); try { errorMessage = JSON.stringify(JSON.parse(text)); @@ -35,7 +38,7 @@ function handleErrorMessage(error) { errorMessage = text; } } - throw new ConfigurationError(`${errorMessage}`); + throw new ConfigurationError(errorMessage); } export default {