@pipedream/pandadoc 0.2.2 → 0.2.4

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.
@@ -5,7 +5,7 @@ export default defineComponent({
5
5
  name: "Send Document",
6
6
  description: "Move a document to sent status and send an optional email. [See the documentation](https://developers.pandadoc.com/reference/send-document)",
7
7
  type: "action",
8
- version: "0.0.2",
8
+ version: "0.0.4",
9
9
  props: {
10
10
  app,
11
11
  documentId: {
@@ -60,6 +60,34 @@ export default defineComponent({
60
60
  },
61
61
  async run({ $ }) {
62
62
  const documentId = this.documentId;
63
+ let documentStatus = "";
64
+ let retryCount = 0;
65
+ const maxRetries = 5; // Maximum number of retries
66
+
67
+ while (documentStatus !== "document.draft" && retryCount < maxRetries) {
68
+ try {
69
+ const response = await this.app.getDocument({
70
+ id: documentId,
71
+ });
72
+ console.log(response);
73
+ documentStatus = response.status;
74
+ if (documentStatus === "document.draft") {
75
+ break;
76
+ }
77
+ console.log(
78
+ `Document status is '${documentStatus}' and not 'document.draft'. Waiting 1s and trying again...`
79
+ );
80
+ await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
81
+ retryCount++;
82
+ } catch (error) {
83
+ console.error("Error fetching document details:", error);
84
+ retryCount++; // Increment the retry count on error
85
+ }
86
+ }
87
+
88
+ if (documentStatus !== "document.draft") {
89
+ console.error(`Maximum retry limit (${maxRetries}) reached. Exiting.`);
90
+ }
63
91
 
64
92
  const data = {
65
93
  subject: this.subject,
@@ -84,7 +112,10 @@ export default defineComponent({
84
112
  data,
85
113
  });
86
114
 
87
- $.export("$summary", `Successfully sent "${response.name}" document with ID: ${response.id} to ${response.recipients.length} recipient(s)`);
115
+ $.export(
116
+ "$summary",
117
+ `Successfully sent "${response.name}" document with ID: ${response.id} to ${response.recipients.length} recipient(s)`
118
+ );
88
119
  return response;
89
120
  },
90
121
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/pandadoc",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Pipedream PandaDoc Components",
5
5
  "main": "pandadoc.app.mjs",
6
6
  "keywords": [