1+ import app from "../docugenerate.app.mjs" ;
2+
3+ export default {
4+ key : "docugenerate-generate-document" ,
5+ name : "Generate Document" ,
6+ description : "Generates a document from a template" ,
7+ version : "0.0.1" ,
8+ type : "action" ,
9+ props : {
10+ app,
11+ templateId : {
12+ propDefinition : [
13+ app ,
14+ "templateId" ,
15+ ] ,
16+ } ,
17+ name : {
18+ type : "string" ,
19+ label : "Name" ,
20+ description : "Name of the generated document. Defaults to the template’s name." ,
21+ } ,
22+ format : {
23+ type : "string" ,
24+ label : "Format" ,
25+ description : "Output format of the generated document. Defaults to .docx." ,
26+ options : [
27+ { label : 'Microsoft Word (.docx)' , value : '.docx' } ,
28+ { label : 'Microsoft Word 2007 (.doc)' , value : '.doc' } ,
29+ { label : 'OpenDocument Format (.odt)' , value : '.odt' } ,
30+ { label : 'PDF (.pdf)' , value : '.pdf' } ,
31+ { label : 'Plain Text (.txt)' , value : '.txt' } ,
32+ { label : 'PNG (.png)' , value : '.png' } ,
33+ ] ,
34+ } ,
35+ data : {
36+ type : "object" ,
37+ label : "Template Data" ,
38+ description : "Data that is used to generate the document." ,
39+ } ,
40+ } ,
41+ async run ( { $ } ) {
42+ const body = {
43+ template_id : this . templateId ,
44+ name : this . name ,
45+ format : this . format ,
46+ data : this . data ,
47+ } ;
48+
49+ const response = await this . app . generateDocument ( $ , body ) ;
50+
51+ $ . export ( "$summary" , `Successfully generated document with ID: ${ response . id } ` ) ;
52+ return response ;
53+ } ,
54+ } ;
0 commit comments