diff --git a/components/docugenerate/README.md b/components/docugenerate/README.md index edbdb54fec2df..cfa08719e8200 100644 --- a/components/docugenerate/README.md +++ b/components/docugenerate/README.md @@ -9,3 +9,25 @@ The DocuGenerate API lets you automate document creation and management tasks wi - **Automated Report Creation and Distribution**: Schedule a workflow to run weekly, gathering data from tools such as Google Sheets or a database. Use this data to create a tailored report via DocuGenerate and subsequently email the report to a list of stakeholders using an email service like SendGrid. - **Dynamic Invoice Creation from E-Commerce Platforms**: When a new order is placed on an e-commerce platform (like Shopify), trigger a Pipedream workflow that creates an invoice through the DocuGenerate API. Then, archive the invoice in cloud storage like Google Drive and update the order status within the e-commerce platform. + +# Getting Started + +## Obtaining Your API Key + +1. Sign up for a [DocuGenerate](https://www.docugenerate.com/) account +2. Get your unique API Key from the Developers tab in the [Settings](https://app.docugenerate.com/settings/developers) page +3. Copy the API Key for use in Pipedream + +## Connecting to Pipedream + +1. In your Pipedream workflow, add a DocuGenerate action +2. When prompted for authentication, paste your API Key +3. Test the connection by using the "List Templates" action + +## Generating Your First Document + +Use the "Generate Document" action with: +- **Template**: Select from your available templates +- **Data**: Provide JSON data matching your template merge tags (e.g., `{ "name": "John Doe" }`) +- **Name**: Set a custom document name (optional) +- **Format**: Choose your desired output format (optional) diff --git a/components/docugenerate/actions/delete-document/delete-document.mjs b/components/docugenerate/actions/delete-document/delete-document.mjs new file mode 100644 index 0000000000000..b0fac514a0712 --- /dev/null +++ b/components/docugenerate/actions/delete-document/delete-document.mjs @@ -0,0 +1,23 @@ +import app from "../../docugenerate.app.mjs"; + +export default { + key: "docugenerate-delete-document", + name: "Delete Document", + description: "Deletes a specific document. [See the documentation](https://api.docugenerate.com/#/Document/deleteDocument)", + version: "0.0.1", + type: "action", + props: { + app, + documentId: { + type: "string", + label: "Document", + description: "The ID of the document", + }, + }, + async run({ $ }) { + const response = await this.app.deleteDocument($, this.documentId); + + $.export("$summary", `Successfully deleted the document ${this.documentId}`); + return response; + }, +}; diff --git a/components/docugenerate/actions/delete-template/delete-template.mjs b/components/docugenerate/actions/delete-template/delete-template.mjs new file mode 100644 index 0000000000000..ac68fcf5fc7f4 --- /dev/null +++ b/components/docugenerate/actions/delete-template/delete-template.mjs @@ -0,0 +1,24 @@ +import app from "../../docugenerate.app.mjs"; + +export default { + key: "docugenerate-delete-template", + name: "Delete Template", + description: "Deletes a specific template. [See the documentation](https://api.docugenerate.com/#/Template/deleteTemplate)", + version: "0.0.1", + type: "action", + props: { + app, + templateId: { + propDefinition: [ + app, + "templateId", + ], + }, + }, + async run({ $ }) { + const response = await this.app.deleteTemplate($, this.templateId); + + $.export("$summary", `Successfully deleted the template ${this.templateId}`); + return response; + }, +}; diff --git a/components/docugenerate/actions/generate-document/generate-document.mjs b/components/docugenerate/actions/generate-document/generate-document.mjs new file mode 100644 index 0000000000000..2a90b6a2e9e0f --- /dev/null +++ b/components/docugenerate/actions/generate-document/generate-document.mjs @@ -0,0 +1,74 @@ +import app from "../../docugenerate.app.mjs"; + +export default { + key: "docugenerate-generate-document", + name: "Generate Document", + description: "Generates a document from a template. [See the documentation](https://api.docugenerate.com/#/Document/generateDocument)", + version: "0.0.1", + type: "action", + props: { + app, + templateId: { + propDefinition: [ + app, + "templateId", + ], + }, + name: { + type: "string", + label: "Name", + description: "Name of the generated document. Defaults to the template’s name.", + optional: true, + }, + format: { + type: "string", + label: "Format", + description: "Output format of the generated document. Defaults to .docx.", + optional: true, + options: [ + { + label: "PDF (.pdf)", + value: ".pdf", + }, + { + label: "Microsoft Word (.docx)", + value: ".docx", + }, + { + label: "Microsoft Word 2007 (.doc)", + value: ".doc", + }, + { + label: "OpenDocument Format (.odt)", + value: ".odt", + }, + { + label: "Plain Text (.txt)", + value: ".txt", + }, + { + label: "PNG (.png)", + value: ".png", + }, + ], + }, + data: { + type: "object", + label: "Data", + description: "Data that is used to generate the document.", + }, + }, + async run({ $ }) { + const body = { + template_id: this.templateId, + name: this.name, + output_format: this.format, + data: this.data, + }; + + const response = await this.app.generateDocument($, body); + + $.export("$summary", `Successfully generated the document ${response.id}`); + return response; + }, +}; diff --git a/components/docugenerate/actions/get-document/get-document.mjs b/components/docugenerate/actions/get-document/get-document.mjs new file mode 100644 index 0000000000000..a33b47b65e0c8 --- /dev/null +++ b/components/docugenerate/actions/get-document/get-document.mjs @@ -0,0 +1,23 @@ +import app from "../../docugenerate.app.mjs"; + +export default { + key: "docugenerate-get-document", + name: "Get Document", + description: "Retrieves a specific document. [See the documentation](https://api.docugenerate.com/#/Document/getDocument)", + version: "0.0.1", + type: "action", + props: { + app, + documentId: { + type: "string", + label: "Document", + description: "The ID of the document", + }, + }, + async run({ $ }) { + const response = await this.app.getDocument($, this.documentId); + + $.export("$summary", `Successfully retrieved the document ${this.documentId}`); + return response; + }, +}; diff --git a/components/docugenerate/actions/get-template/get-template.mjs b/components/docugenerate/actions/get-template/get-template.mjs new file mode 100644 index 0000000000000..db2b8a6711047 --- /dev/null +++ b/components/docugenerate/actions/get-template/get-template.mjs @@ -0,0 +1,24 @@ +import app from "../../docugenerate.app.mjs"; + +export default { + key: "docugenerate-get-template", + name: "Get Template", + description: "Retrieves a specific template. [See the documentation](https://api.docugenerate.com/#/Template/getTemplate)", + version: "0.0.1", + type: "action", + props: { + app, + templateId: { + propDefinition: [ + app, + "templateId", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getTemplate($, this.templateId); + + $.export("$summary", `Successfully retrieved the template ${this.templateId}`); + return response; + }, +}; diff --git a/components/docugenerate/actions/list-documents/list-documents.mjs b/components/docugenerate/actions/list-documents/list-documents.mjs new file mode 100644 index 0000000000000..f05b9ddef437c --- /dev/null +++ b/components/docugenerate/actions/list-documents/list-documents.mjs @@ -0,0 +1,24 @@ +import app from "../../docugenerate.app.mjs"; + +export default { + key: "docugenerate-list-documents", + name: "List Documents", + description: "Retrieves a list of documents generated from a template. [See the documentation](https://api.docugenerate.com/#/Document/queryDocuments)", + version: "0.0.1", + type: "action", + props: { + app, + templateId: { + propDefinition: [ + app, + "templateId", + ], + }, + }, + async run({ $ }) { + const response = await this.app.listDocuments($, this.templateId); + + $.export("$summary", `Successfully retrieved ${response?.length || 0} documents`); + return response; + }, +}; diff --git a/components/docugenerate/actions/list-templates/list-templates.mjs b/components/docugenerate/actions/list-templates/list-templates.mjs new file mode 100644 index 0000000000000..adfe39d1d998c --- /dev/null +++ b/components/docugenerate/actions/list-templates/list-templates.mjs @@ -0,0 +1,18 @@ +import app from "../../docugenerate.app.mjs"; + +export default { + key: "docugenerate-list-templates", + name: "List Templates", + description: "Retrieves a list of all templates. [See the documentation](https://api.docugenerate.com/#/Template/queryTemplates)", + version: "0.0.1", + type: "action", + props: { + app, + }, + async run({ $ }) { + const response = await this.app.listTemplates($); + + $.export("$summary", `Successfully retrieved ${response?.length || 0} templates`); + return response; + }, +}; diff --git a/components/docugenerate/actions/update-document/update-document.mjs b/components/docugenerate/actions/update-document/update-document.mjs new file mode 100644 index 0000000000000..611d445374645 --- /dev/null +++ b/components/docugenerate/actions/update-document/update-document.mjs @@ -0,0 +1,30 @@ +import app from "../../docugenerate.app.mjs"; + +export default { + key: "docugenerate-update-document", + name: "Update Document", + description: "Updates a specific document. [See the documentation](https://api.docugenerate.com/#/Document/updateDocument)", + version: "0.0.1", + type: "action", + props: { + app, + documentId: { + type: "string", + label: "Document", + description: "The ID of the document", + }, + name: { + type: "string", + label: "Name", + description: "The new name for the document", + }, + }, + async run({ $ }) { + const response = await this.app.updateDocument($, this.documentId, { + name: this.name, + }); + + $.export("$summary", `Successfully updated the document ${this.documentId}`); + return response; + }, +}; diff --git a/components/docugenerate/docugenerate.app.mjs b/components/docugenerate/docugenerate.app.mjs index cec28d301296f..6ad6c1a1e53cf 100644 --- a/components/docugenerate/docugenerate.app.mjs +++ b/components/docugenerate/docugenerate.app.mjs @@ -1,11 +1,99 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "docugenerate", - propDefinitions: {}, + propDefinitions: { + templateId: { + type: "string", + label: "Template", + description: "The selected template", + async options() { + const response = await this.listTemplates(); + return response.map((template) => ({ + label: template.name, + value: template.id, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getBaseUrl() { + return "https://api.docugenerate.com/v1"; + }, + getHeaders() { + return { + "Authorization": `${this.$auth.api_key}`, + "Content-Type": "application/json", + }; + }, + async makeRequest({ + $ = this, + method = "GET", + path, + ...args + }) { + const config = { + method, + url: `${this.getBaseUrl()}${path}`, + headers: this.getHeaders(), + ...args, + }; + return axios($, config); + }, + async listTemplates($ = this) { + return this.makeRequest({ + $, + path: "/template", + }); + }, + async getTemplate($ = this, templateId) { + return this.makeRequest({ + $, + path: `/template/${templateId}`, + }); + }, + async deleteTemplate($ = this, templateId) { + return this.makeRequest({ + $, + method: "DELETE", + path: `/template/${templateId}`, + }); + }, + async listDocuments($ = this, templateId) { + return this.makeRequest({ + $, + path: `/document?template_id=${templateId}`, + }); + }, + async getDocument($ = this, documentId) { + return this.makeRequest({ + $, + path: `/document/${documentId}`, + }); + }, + async updateDocument($ = this, documentId, body) { + return this.makeRequest({ + $, + method: "PUT", + path: `/document/${documentId}`, + data: body, + }); + }, + async deleteDocument($ = this, documentId) { + return this.makeRequest({ + $, + method: "DELETE", + path: `/document/${documentId}`, + }); + }, + async generateDocument($ = this, body) { + return this.makeRequest({ + $, + method: "POST", + path: "/document", + data: body, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/docugenerate/package.json b/components/docugenerate/package.json index 58227e2d13194..adb2f51b33ae3 100644 --- a/components/docugenerate/package.json +++ b/components/docugenerate/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/docugenerate", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream DocuGenerate Components", "main": "docugenerate.app.mjs", "keywords": [ @@ -8,8 +8,11 @@ "docugenerate" ], "homepage": "https://pipedream.com/apps/docugenerate", - "author": "Pipedream (https://pipedream.com/)", + "author": "DocuGenerate (https://www.docugenerate.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 00c8c360962ff..65c94c113d4a6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1523,8 +1523,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/beeminder: - specifiers: {} + components/beeminder: {} components/belco: dependencies: @@ -3998,7 +3997,11 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/docugenerate: {} + components/docugenerate: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/documenso: dependencies: @@ -8035,8 +8038,7 @@ importers: specifier: ^1.6.5 version: 1.6.6 - components/lingvanex_translation_api: - specifiers: {} + components/lingvanex_translation_api: {} components/linkedin: dependencies: @@ -25843,9 +25845,6 @@ packages: generate-function@2.3.1: resolution: {integrity: sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==} - generative-bayesian-network@2.1.70: - resolution: {integrity: sha512-nP0CNiVs/QS5ppMsGiEYN3dgAe3UTT1mpDth0wTh9uEyEO4e7y1Yr5PGDcTJsU0Lm3YM21yNzhuPbUg7etKHbQ==} - generic-pool@3.9.0: resolution: {integrity: sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==} engines: {node: '>= 4'} @@ -26292,10 +26291,6 @@ packages: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true - header-generator@2.1.70: - resolution: {integrity: sha512-s2/jN4hIr/pDRZhXA1D2T72eO4f8Gi1mwYEIFLbU+OR7cjo+Tayrw4RlTN3dXPahrU/MBdjk9gv//MwxLoCpGQ==} - engines: {node: '>=16.0.0'} - heap-js@2.5.0: resolution: {integrity: sha512-kUGoI3p7u6B41z/dp33G6OaL7J4DRqRYwVmeIlwLClx7yaaAy7hoDExnuejTKtuDwfcatGmddHDEOjf6EyIxtQ==} engines: {node: '>=10.0.0'} @@ -30974,22 +30969,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@10.0.0: resolution: {integrity: sha512-HRVVSbCCMbj7/kdWF9Q+bbckjBHLtHMEoJWlkmYzzdwhYMkjkOwubLM6t7NbWKjgKamGDrWL1++KrjUO1t9oAQ==} @@ -45401,11 +45396,6 @@ snapshots: dependencies: is-property: 1.0.2 - generative-bayesian-network@2.1.70: - dependencies: - adm-zip: 0.5.16 - tslib: 2.8.1 - generic-pool@3.9.0: {} gensync@1.0.0-beta.2: {} @@ -45854,16 +45844,6 @@ snapshots: gopd@1.2.0: {} - got-scraping@4.1.2: - dependencies: - got: 14.4.6 - header-generator: 2.1.70 - http2-wrapper: 2.2.1 - mimic-response: 4.0.0 - ow: 1.1.1 - quick-lru: 7.1.0 - tslib: 2.8.1 - got@11.8.6: dependencies: '@sindresorhus/is': 4.6.0 @@ -46108,13 +46088,6 @@ snapshots: he@1.2.0: {} - header-generator@2.1.70: - dependencies: - browserslist: 4.24.2 - generative-bayesian-network: 2.1.70 - ow: 0.28.2 - tslib: 2.8.1 - heap-js@2.5.0: {} help-me@3.0.0: