-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Expand file tree
/
Copy pathgenerate-document.mjs
More file actions
79 lines (76 loc) · 1.83 KB
/
Copy pathgenerate-document.mjs
File metadata and controls
79 lines (76 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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.2",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
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;
},
};