@pipedream/pandadoc 0.0.1 → 0.1.0
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.
- package/actions/create-document-attachment/create-document-attachment.mjs +22 -15
- package/actions/create-document-from-file/create-document-from-file.mjs +81 -0
- package/actions/create-document-from-template/create-document-from-template.mjs +10 -13
- package/actions/create-folder/create-folder.mjs +43 -0
- package/actions/create-or-update-contact/create-or-update-contact.mjs +1 -1
- package/actions/document-details/document-details.mjs +1 -1
- package/actions/list-contacts/list-contacts.mjs +1 -1
- package/actions/list-document-attachments/list-document-attachments.mjs +1 -1
- package/actions/list-documents/list-documents.mjs +1 -1
- package/actions/list-folders/list-folders.mjs +34 -0
- package/package.json +2 -2
- package/pandadoc.app.mjs +28 -1
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
name: "Create Document Attachment",
|
|
10
10
|
description: "Adds an attachment to a document. [See the docs here](https://developers.pandadoc.com/reference/create-document-attachment)",
|
|
11
11
|
type: "action",
|
|
12
|
-
version: "0.0.
|
|
12
|
+
version: "0.0.2",
|
|
13
13
|
props: {
|
|
14
14
|
app,
|
|
15
15
|
documentId: {
|
|
@@ -19,9 +19,10 @@ export default {
|
|
|
19
19
|
],
|
|
20
20
|
},
|
|
21
21
|
file: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
propDefinition: [
|
|
23
|
+
app,
|
|
24
|
+
"file",
|
|
25
|
+
],
|
|
25
26
|
},
|
|
26
27
|
fileName: {
|
|
27
28
|
type: "string",
|
|
@@ -49,6 +50,22 @@ export default {
|
|
|
49
50
|
size: stats.size,
|
|
50
51
|
};
|
|
51
52
|
},
|
|
53
|
+
getFormData(file, fileName) {
|
|
54
|
+
const fileValidation = this.isValidFile(file);
|
|
55
|
+
if (!fileValidation) {
|
|
56
|
+
throw new ConfigurationError("`file` must be a valid file path!");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const fileMeta = this.getFileMeta(fileValidation);
|
|
60
|
+
const fileContent = this.getFileStream(fileValidation);
|
|
61
|
+
const data = new FormData();
|
|
62
|
+
if (fileName) data.append("name", fileName);
|
|
63
|
+
data.append("file", fileContent, {
|
|
64
|
+
knownLength: fileMeta.size,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return data;
|
|
68
|
+
},
|
|
52
69
|
},
|
|
53
70
|
async run({ $ }) {
|
|
54
71
|
const {
|
|
@@ -57,17 +74,7 @@ export default {
|
|
|
57
74
|
fileName,
|
|
58
75
|
} = this;
|
|
59
76
|
|
|
60
|
-
const
|
|
61
|
-
if (!fileValidation) {
|
|
62
|
-
throw new ConfigurationError("`file` must be a valid file path!");
|
|
63
|
-
}
|
|
64
|
-
const fileMeta = this.getFileMeta(fileValidation);
|
|
65
|
-
const fileContent = this.getFileStream(fileValidation);
|
|
66
|
-
const data = new FormData();
|
|
67
|
-
data.append("name", fileName);
|
|
68
|
-
data.append("file", fileContent, {
|
|
69
|
-
knownLength: fileMeta.size,
|
|
70
|
-
});
|
|
77
|
+
const data = this.getFormData(file, fileName);
|
|
71
78
|
|
|
72
79
|
const response = await this.app.createDocumentAttachments({
|
|
73
80
|
$,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import app from "../../pandadoc.app.mjs";
|
|
3
|
+
import createDocumentAttachment from "../create-document-attachment/create-document-attachment.mjs";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "pandadoc-create-document-from-file",
|
|
7
|
+
name: "Create Document From File",
|
|
8
|
+
description: "Create a document from a file or public file URL. [See the docs here](https://developers.pandadoc.com/reference/create-document-from-pdf)",
|
|
9
|
+
type: "action",
|
|
10
|
+
version: "0.0.1",
|
|
11
|
+
props: {
|
|
12
|
+
app,
|
|
13
|
+
name: {
|
|
14
|
+
propDefinition: [
|
|
15
|
+
app,
|
|
16
|
+
"name",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
recipients: {
|
|
20
|
+
propDefinition: [
|
|
21
|
+
app,
|
|
22
|
+
"recipients",
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
file: {
|
|
26
|
+
propDefinition: [
|
|
27
|
+
app,
|
|
28
|
+
"file",
|
|
29
|
+
],
|
|
30
|
+
optional: true,
|
|
31
|
+
},
|
|
32
|
+
fileUrl: {
|
|
33
|
+
type: "string",
|
|
34
|
+
label: "File URL",
|
|
35
|
+
description: "A public file URL to use instead of a local file.",
|
|
36
|
+
optional: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
methods: createDocumentAttachment.methods,
|
|
40
|
+
async run({ $ }) {
|
|
41
|
+
const {
|
|
42
|
+
name,
|
|
43
|
+
recipients,
|
|
44
|
+
file,
|
|
45
|
+
fileUrl,
|
|
46
|
+
} = this;
|
|
47
|
+
|
|
48
|
+
let parsedRecipients;
|
|
49
|
+
try {
|
|
50
|
+
parsedRecipients = recipients.map((s) => JSON.parse(s));
|
|
51
|
+
} catch (err) {
|
|
52
|
+
throw new ConfigurationError("**Error parsing recipients** - each must be a valid JSON-stringified object");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let data, contentType, json = {
|
|
56
|
+
name,
|
|
57
|
+
recipients: parsedRecipients,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
if (fileUrl) {
|
|
61
|
+
data = json;
|
|
62
|
+
contentType = "application/json";
|
|
63
|
+
data.url = fileUrl;
|
|
64
|
+
} else {
|
|
65
|
+
data = this.getFormData(file);
|
|
66
|
+
contentType = `multipart/form-data; boundary=${data._boundary}`;
|
|
67
|
+
data.append("data", JSON.stringify(json));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const response = await this.app.createDocument({
|
|
71
|
+
$,
|
|
72
|
+
data,
|
|
73
|
+
headers: {
|
|
74
|
+
"Content-Type": contentType,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
$.export("$summary", `Successfully created document attachment with ID: ${response.uuid}`);
|
|
79
|
+
return response;
|
|
80
|
+
},
|
|
81
|
+
};
|
|
@@ -5,13 +5,14 @@ export default {
|
|
|
5
5
|
name: "Create Document From Template",
|
|
6
6
|
description: "Create Document from PandaDoc Template. [See the docs here](https://developers.pandadoc.com/reference/create-document-from-pandadoc-template)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
name: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
propDefinition: [
|
|
13
|
+
app,
|
|
14
|
+
"name",
|
|
15
|
+
],
|
|
15
16
|
},
|
|
16
17
|
templateId: {
|
|
17
18
|
propDefinition: [
|
|
@@ -32,14 +33,10 @@ export default {
|
|
|
32
33
|
optional: true,
|
|
33
34
|
},
|
|
34
35
|
recipients: {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
If not passed, a person will receive a read-only link to view the document.
|
|
40
|
-
If the first_name and last_name not passed the system: 1. creates a new contact,
|
|
41
|
-
if none exists with the given email; or 2. gets the existing contact with the given email that already exists.
|
|
42
|
-
\n\nE.g. \`{ "email": "john.doe@pipedream.com", "first_name": "John", "last_name": "Doe" }\``,
|
|
36
|
+
propDefinition: [
|
|
37
|
+
app,
|
|
38
|
+
"recipients",
|
|
39
|
+
],
|
|
43
40
|
},
|
|
44
41
|
tokens: {
|
|
45
42
|
type: "string[]",
|
|
@@ -74,7 +71,7 @@ export default {
|
|
|
74
71
|
tokens,
|
|
75
72
|
} = this;
|
|
76
73
|
|
|
77
|
-
const response = await this.app.
|
|
74
|
+
const response = await this.app.createDocument({
|
|
78
75
|
$,
|
|
79
76
|
data: {
|
|
80
77
|
name,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import app from "../../pandadoc.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "pandadoc-create-folder",
|
|
5
|
+
name: "Create Folder",
|
|
6
|
+
description: "Create a new folder to store your documents. [See the docs here](https://developers.pandadoc.com/reference/create-documents-folder)",
|
|
7
|
+
type: "action",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
props: {
|
|
10
|
+
app,
|
|
11
|
+
name: {
|
|
12
|
+
type: "string",
|
|
13
|
+
label: "Name",
|
|
14
|
+
description: "Name the folder for Documents you are creating.",
|
|
15
|
+
},
|
|
16
|
+
parentFolderId: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
app,
|
|
19
|
+
"documentFolderId",
|
|
20
|
+
],
|
|
21
|
+
label: "Parent Folder ID",
|
|
22
|
+
description: "The ID of a parent folder. If not set, the new folder will be created in the root folder.",
|
|
23
|
+
optional: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
async run({ $ }) {
|
|
27
|
+
const {
|
|
28
|
+
name,
|
|
29
|
+
parentFolderId,
|
|
30
|
+
} = this;
|
|
31
|
+
|
|
32
|
+
const response = await this.app.createFolder({
|
|
33
|
+
$,
|
|
34
|
+
data: {
|
|
35
|
+
name,
|
|
36
|
+
parent_uuid: parentFolderId,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
$.export("$summary", `Successfully created folder "${response.name ?? response.uuid}"`);
|
|
41
|
+
return response;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Create or Update Contact",
|
|
6
6
|
description: "This method adds or updates a contact using the email as index. [See the docs here](https://developers.pandadoc.com/reference/create-contact)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
email: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "Document Details",
|
|
6
6
|
description: "Return detailed data about a document. [See the docs here](https://developers.pandadoc.com/reference/document-details)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
id: {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "List Contacts",
|
|
6
6
|
description: "This method lists all contacts within an account. [See the docs here](https://developers.pandadoc.com/reference/list-contacts)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
},
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "List Document Attachment",
|
|
6
6
|
description: "Returns a list of attachments associated with a specified document. [See the docs here](https://developers.pandadoc.com/reference/list-attachment)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.2",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
documentId: {
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
name: "List Documents",
|
|
7
7
|
description: "List documents optionally filter by a search query or tags. [See the docs here](https://developers.pandadoc.com/reference/list-documents)",
|
|
8
8
|
type: "action",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.2",
|
|
10
10
|
props: {
|
|
11
11
|
app,
|
|
12
12
|
query: {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import app from "../../pandadoc.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "pandadoc-list-folders",
|
|
5
|
+
name: "List Folders",
|
|
6
|
+
description: "List folders which contain Documents [See the docs here](https://developers.pandadoc.com/reference/list-documents-folders)",
|
|
7
|
+
type: "action",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
props: {
|
|
10
|
+
app,
|
|
11
|
+
parentFolderId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
app,
|
|
14
|
+
"documentFolderId",
|
|
15
|
+
],
|
|
16
|
+
label: "Parent Folder ID",
|
|
17
|
+
description: "The ID of a parent folder whose folders to list. If not set, the root folder will be used.",
|
|
18
|
+
optional: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
async run({ $ }) {
|
|
22
|
+
const { parentFolderId } = this;
|
|
23
|
+
|
|
24
|
+
const response = await this.app.listDocumentFolders({
|
|
25
|
+
$,
|
|
26
|
+
params: {
|
|
27
|
+
parent_uuid: parentFolderId,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
$.export("$summary", `Successfully fetched ${response?.results?.length} folders`);
|
|
32
|
+
return response;
|
|
33
|
+
},
|
|
34
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/pandadoc",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pipedream PandaDoc Components",
|
|
5
5
|
"main": "pandadoc.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@pipedream/platform": "^1.
|
|
17
|
+
"@pipedream/platform": "^1.4.1",
|
|
18
18
|
"form-data": "^4.0.0"
|
|
19
19
|
}
|
|
20
20
|
}
|
package/pandadoc.app.mjs
CHANGED
|
@@ -58,6 +58,26 @@ export default {
|
|
|
58
58
|
})) || [];
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
|
+
file: {
|
|
62
|
+
type: "string",
|
|
63
|
+
label: "File",
|
|
64
|
+
description: "The file to upload from the `/tmp` folder. [See the docs here] on how to upload a file to `/tmp`.(https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)",
|
|
65
|
+
},
|
|
66
|
+
name: {
|
|
67
|
+
type: "string",
|
|
68
|
+
label: "Document Name",
|
|
69
|
+
description: "Specify the document's name.",
|
|
70
|
+
},
|
|
71
|
+
recipients: {
|
|
72
|
+
type: "string[]",
|
|
73
|
+
label: "Recipients",
|
|
74
|
+
description: `The list of recipients you're sending the document to. Every object must contain the email parameter.
|
|
75
|
+
The role, first_name and last_name parameters are optional. If the role parameter passed, a person is assigned all fields matching their corresponding role.
|
|
76
|
+
If not passed, a person will receive a read-only link to view the document.
|
|
77
|
+
If the first_name and last_name not passed the system: 1. creates a new contact,
|
|
78
|
+
if none exists with the given email; or 2. gets the existing contact with the given email that already exists.
|
|
79
|
+
\n\nE.g. \`{ "email": "john.doe@pipedream.com", "first_name": "John", "last_name": "Doe" }\``,
|
|
80
|
+
},
|
|
61
81
|
},
|
|
62
82
|
methods: {
|
|
63
83
|
getUrl(path) {
|
|
@@ -121,13 +141,20 @@ export default {
|
|
|
121
141
|
...args,
|
|
122
142
|
});
|
|
123
143
|
},
|
|
124
|
-
|
|
144
|
+
createDocument(args = {}) {
|
|
125
145
|
return this.makeRequest({
|
|
126
146
|
path: "/documents",
|
|
127
147
|
method: "POST",
|
|
128
148
|
...args,
|
|
129
149
|
});
|
|
130
150
|
},
|
|
151
|
+
createFolder(args = {}) {
|
|
152
|
+
return this.makeRequest({
|
|
153
|
+
path: "/documents/folders",
|
|
154
|
+
method: "POST",
|
|
155
|
+
...args,
|
|
156
|
+
});
|
|
157
|
+
},
|
|
131
158
|
createOrUpdateContact(args = {}) {
|
|
132
159
|
return this.makeRequest({
|
|
133
160
|
path: "/contacts",
|