-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New Components - ignisign #14577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - ignisign #14577
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ca701df
ignisign init
luancazarine 24c69b0
[Components] ignisign #14570
luancazarine 5128116
pnpm update
luancazarine 32c9d06
fix check component app prop step
luancazarine 711b771
pnpm update
luancazarine 94a9550
some adjusts
luancazarine e272e40
Update components/ignisign/sources/new-signature-proof-instant/new-si…
luancazarine ad2e457
some adjusts
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
139 changes: 139 additions & 0 deletions
139
components/ignisign/actions/create-signature-request/create-signature-request.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| 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.", | ||
| }, | ||
| 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.closeSignatureRequest({ | ||
| 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, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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, | ||
| }; | ||
| }, | ||
| }; | ||
95 changes: 95 additions & 0 deletions
95
components/ignisign/actions/create-signer/create-signer.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| 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, | ||
| signerProfileId: { | ||
| propDefinition: [ | ||
| ignisign, | ||
| "signerProfileId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| externalId: { | ||
| propDefinition: [ | ||
| ignisign, | ||
| "externalId", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| firstName: { | ||
| propDefinition: [ | ||
| ignisign, | ||
| "firstName", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| lastName: { | ||
| propDefinition: [ | ||
| ignisign, | ||
| "lastName", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| email: { | ||
| propDefinition: [ | ||
| ignisign, | ||
| "email", | ||
| ], | ||
| }, | ||
| 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; | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
47 changes: 47 additions & 0 deletions
47
components/ignisign/actions/get-signature-proof/get-signature-proof.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}`, | ||
| }; | ||
| }, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| }; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const checkTmp = (filename) => { | ||
| if (!filename.startsWith("/tmp")) { | ||
| return `/tmp/${filename}`; | ||
| } | ||
| return filename; | ||
| }; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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; | ||
| }; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.