-
Notifications
You must be signed in to change notification settings - Fork 5.5k
DocuGenerate - new components #18164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ee977d0
Create the "List Templates" action.
docugenerate d222ea5
Update "List Templates" action with the correct URL.
docugenerate 82ea93f
Update for the "templateId" prop.
docugenerate 13365fe
Add success message with $.export("$summary")
docugenerate edf128f
Add the "Delete Template" action.
docugenerate 33b92b7
Create the "List Documents" action.
docugenerate 7dd2c3a
Add the "Get Document" action.
docugenerate f64d548
Update the "Get Document" action.
docugenerate 9e7c4a2
Add the "Update Document" action.
docugenerate 8f23625
Add the "Delete Document" action.
docugenerate d3b9341
Add "Generate Document" action.
docugenerate 99471ff
Add "Generate Document" action.
docugenerate b3f30aa
Add optional fields.
docugenerate e338990
Update output format options.
docugenerate cb1c952
Update summary message.
docugenerate 128e97c
Set version: "1.0.0" for all actions.
docugenerate d0d6347
Update package.json
docugenerate a95e98f
Update README file.
docugenerate 7957346
Merge branch 'master' into docugenerate
docugenerate 86b0a53
Fix step numbering in README.
docugenerate 70fa53a
Merge branch 'master' into docugenerate
GTFalcao eb7bdcb
Running eslint --fix
GTFalcao 67aacce
Moving actions to individual folders
GTFalcao 5bd9e80
Adding docs links to descriptions
GTFalcao d21218f
Fixing package version
GTFalcao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
components/docugenerate/actions/delete-document/delete-document.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
| }; | ||
24 changes: 24 additions & 0 deletions
24
components/docugenerate/actions/delete-template/delete-template.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
| }; |
74 changes: 74 additions & 0 deletions
74
components/docugenerate/actions/generate-document/generate-document.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
| }; |
23 changes: 23 additions & 0 deletions
23
components/docugenerate/actions/get-document/get-document.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
| }; |
24 changes: 24 additions & 0 deletions
24
components/docugenerate/actions/get-template/get-template.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
| }; |
24 changes: 24 additions & 0 deletions
24
components/docugenerate/actions/list-documents/list-documents.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
| }; |
18 changes: 18 additions & 0 deletions
18
components/docugenerate/actions/list-templates/list-templates.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
| }; |
30 changes: 30 additions & 0 deletions
30
components/docugenerate/actions/update-document/update-document.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add
async optionsto thedocumentIdprop and reuse it as a propDefinition, in the same fashion as was done withtemplateId?I see the API allows listing documents, so this shouldn't be a problem, and would make for much better usability
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @GTFalcao this is highly appreciated!
For the
documentIdwe'd like to keep it as is if possible. The number of templates is usually reasonably small, so a dropdown for the templates is a great UX choice. However, there can be a lot of generated documents for a given template, so just using the ID for documents is simpler. Hope this makes sense.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see @docugenerate , no problem. Pipedream's workflow UI has a search filter to help narrow down the options precisely for these large options.
Should you ever add pagination or a query/search parameter, both of these are supported in our options model as well.
In any case, we can leave it as it is if you believe it is fine for your use case. I'll move the PR forward to QA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, thank you @GTFalcao! Appreciate your help with getting our PR merged 👍