Skip to content

Commit 70aca9e

Browse files
New Components - ignisign (#14577)
* ignisign init * [Components] ignisign #14570 Sources - New Signature Proof (Instant) Actions - Create Signer - Create Signature Request - Get Signature Proof * pnpm update * fix check component app prop step * pnpm update * some adjusts * Update components/ignisign/sources/new-signature-proof-instant/new-signature-proof-instant.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * some adjusts --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3b8eb5d commit 70aca9e

File tree

10 files changed

+729
-21
lines changed

10 files changed

+729
-21
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import FormData from "form-data";
3+
import fs from "fs";
4+
import { LANGUAGE_OPTIONS } from "../../common/constants.mjs";
5+
import {
6+
checkTmp, parseObject,
7+
} from "../../common/utils.mjs";
8+
import ignisign from "../../ignisign.app.mjs";
9+
10+
export default {
11+
key: "ignisign-create-signature-request",
12+
name: "Create Signature Request",
13+
description: "Creates a document signature request through IgniSign. [See the documentation](https://ignisign.io/docs/ignisign-api/init-signature-request)",
14+
version: "0.0.1",
15+
type: "action",
16+
props: {
17+
ignisign,
18+
signerIds: {
19+
propDefinition: [
20+
ignisign,
21+
"signerIds",
22+
],
23+
},
24+
documentLabel: {
25+
type: "string",
26+
label: "Document Label",
27+
description: "A user-friendly label to identify the document.",
28+
optional: true,
29+
},
30+
documentDescription: {
31+
type: "string",
32+
label: "Document Description",
33+
description: "A detailed, human-readable description of the document.",
34+
optional: true,
35+
},
36+
documentExternalId: {
37+
type: "string",
38+
label: "Document External Id",
39+
description: "An optional external identifier that can be used to reference the document from external systems. It's a free text. Ignisign's system do not interprete it.",
40+
optional: true,
41+
},
42+
file: {
43+
type: "string",
44+
label: "Document File",
45+
description: "The file to be uploaded, please provide a file from `/tmp`. To upload a file to `/tmp` folder, please follow the doc [here](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp)",
46+
},
47+
title: {
48+
type: "string",
49+
label: "Title",
50+
description: "The title of the signature request.",
51+
},
52+
description: {
53+
type: "string",
54+
label: "Description",
55+
description: "The description of the signature request.",
56+
optional: true,
57+
},
58+
expirationDateIsActivated: {
59+
type: "boolean",
60+
label: "Expiration Date Is Activated",
61+
description: "Indicates whether the expiration date is activated.",
62+
reloadProps: true,
63+
optional: true,
64+
},
65+
expirationDate: {
66+
type: "string",
67+
label: "Expiration Date",
68+
description: "The expiration date. The action linked to this date is performed every 5 minutes, at 5, 10, 15... 55.",
69+
optional: true,
70+
hidden: true,
71+
},
72+
language: {
73+
type: "string",
74+
label: "Language",
75+
description: "Represents the languages for signatures supported by a signature profile.",
76+
options: LANGUAGE_OPTIONS,
77+
optional: true,
78+
},
79+
},
80+
async additionalProps(props) {
81+
props.expirationDate.hidden = !this.expirationDateIsActivated;
82+
return {};
83+
},
84+
async run({ $ }) {
85+
const data = new FormData();
86+
87+
const { signatureRequestId } = await this.ignisign.initSignatureRequest();
88+
89+
const { documentId } = await this.ignisign.initDocument({
90+
data: {
91+
signatureRequestId,
92+
label: this.documentLabel,
93+
description: this.documentDescription,
94+
externalId: this.documentExternalId,
95+
},
96+
});
97+
98+
const path = checkTmp(this.file);
99+
if (!fs.existsSync(path)) {
100+
await this.ignisign.closeSignatureRequest({
101+
signatureRequestId,
102+
});
103+
throw new ConfigurationError("File does not exist!");
104+
}
105+
const file = fs.createReadStream(path);
106+
data.append("file", file);
107+
108+
await this.ignisign.uploadFile({
109+
documentId,
110+
data,
111+
headers: data.getHeaders(),
112+
});
113+
114+
await this.ignisign.updateSignatureRequest({
115+
signatureRequestId,
116+
data: {
117+
title: this.title,
118+
description: this.description,
119+
expirationDateIsActivated: this.expirationDateIsActivated,
120+
expirationDate: this.expirationDate,
121+
language: this.language,
122+
documentIds: [
123+
documentId,
124+
],
125+
signerIds: parseObject(this.signerIds),
126+
},
127+
});
128+
129+
await this.ignisign.publishSignatureRequest({
130+
$,
131+
signatureRequestId,
132+
});
133+
134+
$.export("$summary", `Successfully published signature request with ID ${signatureRequestId}`);
135+
return {
136+
signatureRequestId,
137+
};
138+
},
139+
};
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import ignisign from "../../ignisign.app.mjs";
2+
3+
export default {
4+
key: "ignisign-create-signer",
5+
name: "Create Signer",
6+
description: "Creates a new signer entity in IgniSign. [See the documentation](https://ignisign.io/docs/ignisign-api/create-signer)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
ignisign,
11+
signerProfileId: {
12+
propDefinition: [
13+
ignisign,
14+
"signerProfileId",
15+
],
16+
optional: true,
17+
},
18+
externalId: {
19+
propDefinition: [
20+
ignisign,
21+
"externalId",
22+
],
23+
optional: true,
24+
},
25+
firstName: {
26+
propDefinition: [
27+
ignisign,
28+
"firstName",
29+
],
30+
optional: true,
31+
},
32+
lastName: {
33+
propDefinition: [
34+
ignisign,
35+
"lastName",
36+
],
37+
optional: true,
38+
},
39+
email: {
40+
propDefinition: [
41+
ignisign,
42+
"email",
43+
],
44+
},
45+
phoneNumber: {
46+
propDefinition: [
47+
ignisign,
48+
"phoneNumber",
49+
],
50+
optional: true,
51+
},
52+
nationality: {
53+
propDefinition: [
54+
ignisign,
55+
"nationality",
56+
],
57+
optional: true,
58+
},
59+
birthDate: {
60+
propDefinition: [
61+
ignisign,
62+
"birthDate",
63+
],
64+
optional: true,
65+
},
66+
birthPlace: {
67+
propDefinition: [
68+
ignisign,
69+
"birthPlace",
70+
],
71+
optional: true,
72+
},
73+
birthCountry: {
74+
propDefinition: [
75+
ignisign,
76+
"birthCountry",
77+
],
78+
optional: true,
79+
},
80+
},
81+
async run({ $ }) {
82+
const {
83+
ignisign,
84+
...data
85+
} = this;
86+
87+
const response = await ignisign.createSigner({
88+
$,
89+
data,
90+
});
91+
92+
$.export("$summary", `Successfully created signer with ID: ${response.signerId}`);
93+
return response;
94+
},
95+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import fs from "fs";
2+
import stream from "stream";
3+
import { promisify } from "util";
4+
import ignisign from "../../ignisign.app.mjs";
5+
6+
export default {
7+
key: "ignisign-get-signature-proof",
8+
name: "Get Signature Proof",
9+
description: "Retrieves a proof file for a specific signature. [See the documentation](https://ignisign.io/docs/category/ignisign-api)",
10+
version: "0.0.1",
11+
type: "action",
12+
props: {
13+
ignisign,
14+
signatureRequestId: {
15+
propDefinition: [
16+
ignisign,
17+
"signatureRequestId",
18+
],
19+
},
20+
documentId: {
21+
propDefinition: [
22+
ignisign,
23+
"documentId",
24+
({ signatureRequestId }) => ({
25+
signatureRequestId,
26+
}),
27+
],
28+
withLabel: true,
29+
},
30+
},
31+
async run({ $ }) {
32+
const response = await this.ignisign.getSignatureProof({
33+
$,
34+
documentId: this.documentId.value,
35+
responseType: "stream",
36+
});
37+
38+
const pipeline = promisify(stream.pipeline);
39+
await pipeline(response, fs.createWriteStream(`/tmp/${this.documentId.label}`));
40+
41+
$.export("$summary", `Successfully retrieved signature proof for request ID: ${this.signatureRequestId} and saved in /tmp directory.`);
42+
return {
43+
filename: this.documentId.label,
44+
filepath: `/tmp/${this.documentId.label}`,
45+
};
46+
},
47+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const LANGUAGE_OPTIONS = [
2+
"EN",
3+
"FR",
4+
"DE",
5+
"ES",
6+
"IT",
7+
"PT",
8+
"NL",
9+
"PL",
10+
"JA",
11+
"KO",
12+
"AR",
13+
"HE",
14+
];
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
export const camelCaseToTitleCase = (text) => {
2+
const result = text.replace(/([A-Z])/g, " $1");
3+
return result.charAt(0).toUpperCase() + result.slice(1);
4+
};
5+
6+
export const checkTmp = (filename) => {
7+
if (!filename.startsWith("/tmp")) {
8+
return `/tmp/${filename}`;
9+
}
10+
return filename;
11+
};
12+
13+
export const parseObject = (obj) => {
14+
if (!obj) return undefined;
15+
16+
if (Array.isArray(obj)) {
17+
return obj.map((item) => {
18+
if (typeof item === "string") {
19+
try {
20+
return JSON.parse(item);
21+
} catch (e) {
22+
return item;
23+
}
24+
}
25+
return item;
26+
});
27+
}
28+
if (typeof obj === "string") {
29+
try {
30+
return JSON.parse(obj);
31+
} catch (e) {
32+
return obj;
33+
}
34+
}
35+
return obj;
36+
};

0 commit comments

Comments
 (0)