@pipedream/google_drive 0.4.13 → 0.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "google_drive-create-file-from-template",
|
|
9
9
|
name: "Create New File From Template",
|
|
10
10
|
description: "Create a new Google Docs file from a template. Optionally include placeholders in the template document that will get replaced from this action. [See documentation](https://www.npmjs.com/package/google-docs-mustaches)",
|
|
11
|
-
version: "0.0.
|
|
11
|
+
version: "0.0.5",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
googleDrive,
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
"fileId",
|
|
19
19
|
],
|
|
20
20
|
description:
|
|
21
|
-
"Select the document you'd like to use as the template, or use a custom expression to reference a document ID from a previous step.",
|
|
21
|
+
"Select the template document you'd like to use as the template, or use a custom expression to reference a document ID from a previous step. Template documents should contain placeholders in the format {{xyz}}.",
|
|
22
22
|
},
|
|
23
23
|
folderId: {
|
|
24
24
|
propDefinition: [
|
|
@@ -50,7 +50,6 @@ export default {
|
|
|
50
50
|
type: "object",
|
|
51
51
|
label: "Replace text placeholders",
|
|
52
52
|
description: "Replace text placeholders in the document. Use the format {{xyz}} in the document but exclude the curly braces in the key. (eg. `{{myPlaceholder}}` in the document will be replaced by the value of the key `myPlaceholder` in the action.",
|
|
53
|
-
optional: true,
|
|
54
53
|
},
|
|
55
54
|
},
|
|
56
55
|
async run({ $ }) {
|
|
@@ -66,12 +65,24 @@ export default {
|
|
|
66
65
|
|
|
67
66
|
/* CREATE THE GOOGLE DOC */
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
let googleDocId;
|
|
69
|
+
try {
|
|
70
|
+
googleDocId = await client.interpolate({
|
|
71
|
+
source: this.templateId,
|
|
72
|
+
destination: this.folderId,
|
|
73
|
+
name: this.name,
|
|
74
|
+
data: this.replaceValues,
|
|
75
|
+
});
|
|
76
|
+
} catch (e) {
|
|
77
|
+
const {
|
|
78
|
+
code, message,
|
|
79
|
+
} = e.error.error;
|
|
80
|
+
let errorMessage = `Status: ${code}, ${message} `;
|
|
81
|
+
if (code == 404 || code == 400) {
|
|
82
|
+
errorMessage += "Make sure that the template file selected contains placeholders in the format {{xyz}}.";
|
|
83
|
+
}
|
|
84
|
+
throw new Error(errorMessage);
|
|
85
|
+
}
|
|
75
86
|
result["googleDocId"] = googleDocId;
|
|
76
87
|
|
|
77
88
|
/* CREATE THE PDF */
|