Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { ConfigurationError } from "@pipedream/platform";
import FormData from "form-data";
import fs from "fs";
import { LANGUAGE_OPTIONS } from "../../common/constants.mjs";
import {
checkTmp, parseObject,
} from "../../common/utils.mjs";
import ignisign from "../../ignisign.app.mjs";

export default {
key: "ignisign-create-signature-request",
name: "Create Signature Request",
description: "Creates a document signature request through IgniSign. [See the documentation](https://ignisign.io/docs/ignisign-api/init-signature-request)",
version: "0.0.1",
type: "action",
props: {
ignisign,
signerIds: {
propDefinition: [
ignisign,
"signerIds",
],
},
documentLabel: {
type: "string",
label: "Document Label",
description: "A user-friendly label to identify the document.",
optional: true,
},
documentDescription: {
type: "string",
label: "Document Description",
description: "A detailed, human-readable description of the document.",
optional: true,
},
documentExternalId: {
type: "string",
label: "Document External Id",
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.",
optional: true,
},
file: {
type: "string",
label: "Document File",
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)",
},
title: {
type: "string",
label: "Title",
description: "The title of the signature request.",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "The description of the signature request.",
optional: true,
},
expirationDateIsActivated: {
type: "boolean",
label: "Expiration Date Is Activated",
description: "Indicates whether the expiration date is activated.",
reloadProps: true,
optional: true,
},
expirationDate: {
type: "string",
label: "Expiration Date",
description: "The expiration date. The action linked to this date is performed every 5 minutes, at 5, 10, 15... 55.",
optional: true,
hidden: true,
},
language: {
type: "string",
label: "Language",
description: "Represents the languages for signatures supported by a signature profile.",
options: LANGUAGE_OPTIONS,
optional: true,
},
},
async additionalProps(props) {
props.expirationDate.hidden = !this.expirationDateIsActivated;
return {};
},
async run({ $ }) {
const data = new FormData();

const { signatureRequestId } = await this.ignisign.initSignatureRequest();

const { documentId } = await this.ignisign.initDocument({
data: {
signatureRequestId,
label: this.documentLabel,
description: this.documentDescription,
externalId: this.documentExternalId,
},
});

const path = checkTmp(this.file);
if (!fs.existsSync(path)) {
await this.ignisign.deleteSignatureRequest({
signatureRequestId,
});
throw new ConfigurationError("File does not exist!");
}
const file = fs.createReadStream(path);
data.append("file", file);

await this.ignisign.uploadFile({
documentId,
data,
headers: data.getHeaders(),
});

await this.ignisign.updateSignatureRequest({
signatureRequestId,
data: {
title: this.title,
description: this.description,
expirationDateIsActivated: this.expirationDateIsActivated,
expirationDate: this.expirationDate,
language: this.language,
documentIds: [
documentId,
],
signerIds: parseObject(this.signerIds),
},
});

await this.ignisign.publishSignatureRequest({
$,
signatureRequestId,
});

$.export("$summary", `Successfully published signature request with ID ${signatureRequestId}`);
return {
signatureRequestId,
};
},
};
96 changes: 96 additions & 0 deletions components/ignisign/actions/create-signer/create-signer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import ignisign from "../../ignisign.app.mjs";

export default {
key: "ignisign-create-signer",
name: "Create Signer",
description: "Creates a new signer entity in IgniSign. [See the documentation](https://ignisign.io/docs/ignisign-api/create-signer)",
version: "0.0.1",
type: "action",
props: {
ignisign,
signatureProfileId: {
propDefinition: [
ignisign,
"signatureProfileId",
],
optional: true,
},
externalId: {
propDefinition: [
ignisign,
"externalId",
],
optional: true,
},
firstName: {
propDefinition: [
ignisign,
"firstName",
],
optional: true,
},
lastName: {
propDefinition: [
ignisign,
"lastName",
],
optional: true,
},
email: {
propDefinition: [
ignisign,
"email",
],
optional: true,
},
phoneNumber: {
propDefinition: [
ignisign,
"phoneNumber",
],
optional: true,
},
nationality: {
propDefinition: [
ignisign,
"nationality",
],
optional: true,
},
birthDate: {
propDefinition: [
ignisign,
"birthDate",
],
optional: true,
},
birthPlace: {
propDefinition: [
ignisign,
"birthPlace",
],
optional: true,
},
birthCountry: {
propDefinition: [
ignisign,
"birthCountry",
],
optional: true,
},
},
async run({ $ }) {
const {
ignisign,
...data
} = this;

const response = await ignisign.createSigner({
$,
data,
});

$.export("$summary", `Successfully created signer with ID: ${response.signerId}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import fs from "fs";
import stream from "stream";
import { promisify } from "util";
import ignisign from "../../ignisign.app.mjs";

export default {
key: "ignisign-get-signature-proof",
name: "Get Signature Proof",
description: "Retrieves a proof file for a specific signature. [See the documentation](https://ignisign.io/docs/category/ignisign-api)",
version: "0.0.1",
type: "action",
props: {
ignisign,
signatureRequestId: {
propDefinition: [
ignisign,
"signatureRequestId",
],
},
documentId: {
propDefinition: [
ignisign,
"documentId",
({ signatureRequestId }) => ({
signatureRequestId,
}),
],
withLabel: true,
},
},
async run({ $ }) {
const response = await this.ignisign.getSignatureProof({
$,
documentId: this.documentId.value,
responseType: "stream",
});

const pipeline = promisify(stream.pipeline);
await pipeline(response, fs.createWriteStream(`/tmp/${this.documentId.label}`));

$.export("$summary", `Successfully retrieved signature proof for request ID: ${this.signatureRequestId} and saved in /tmp directory.`);
return {
filename: this.documentId.label,
filepath: `/tmp/${this.documentId.label}`,
};
},
};
14 changes: 14 additions & 0 deletions components/ignisign/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const LANGUAGE_OPTIONS = [
"EN",
"FR",
"DE",
"ES",
"IT",
"PT",
"NL",
"PL",
"JA",
"KO",
"AR",
"HE",
];
36 changes: 36 additions & 0 deletions components/ignisign/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export const camelCaseToTitleCase = (text) => {
const result = text.replace(/([A-Z])/g, " $1");
return result.charAt(0).toUpperCase() + result.slice(1);
};

export const checkTmp = (filename) => {
if (!filename.startsWith("/tmp")) {
return `/tmp/${filename}`;
}
return filename;
};

export const parseObject = (obj) => {
if (!obj) return undefined;

if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};
Loading
Loading