From 0282c90b8a2a4e8a0769195f646851a51d62fdb4 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Thu, 24 Oct 2024 15:15:42 -0300 Subject: [PATCH 1/5] papersign init --- .../actions/copy-document/copy-document.mjs | 60 +++++++++ .../actions/get-document/get-document.mjs | 27 ++++ .../actions/send-document/send-document.mjs | 82 ++++++++++++ components/papersign/package.json | 2 +- components/papersign/papersign.app.mjs | 123 +++++++++++++++++- .../new-document-completed-instant.mjs | 71 ++++++++++ .../new-event-instant/new-event-instant.mjs | 71 ++++++++++ .../new-signer-signed-instant.mjs | 100 ++++++++++++++ 8 files changed, 530 insertions(+), 6 deletions(-) create mode 100644 components/papersign/actions/copy-document/copy-document.mjs create mode 100644 components/papersign/actions/get-document/get-document.mjs create mode 100644 components/papersign/actions/send-document/send-document.mjs create mode 100644 components/papersign/sources/new-document-completed-instant/new-document-completed-instant.mjs create mode 100644 components/papersign/sources/new-event-instant/new-event-instant.mjs create mode 100644 components/papersign/sources/new-signer-signed-instant/new-signer-signed-instant.mjs diff --git a/components/papersign/actions/copy-document/copy-document.mjs b/components/papersign/actions/copy-document/copy-document.mjs new file mode 100644 index 0000000000000..b0ffa6868f7e3 --- /dev/null +++ b/components/papersign/actions/copy-document/copy-document.mjs @@ -0,0 +1,60 @@ +import papersign from "../../papersign.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "papersign-copy-document", + name: "Copy Document", + description: "Duplicates a given document. [See the documentation](https://paperform.readme.io/reference/papersigncopydocument)", + version: "0.0.{{ts}}", + type: "action", + props: { + papersign, + documentId: { + propDefinition: [ + papersign, + "documentId", + ], + }, + name: { + type: "string", + label: "Name", + description: "The new name of the copied document", + optional: true, + }, + spaceId: { + propDefinition: [ + papersign, + "spaceId", + ], + optional: true, + }, + path: { + type: "string", + label: "Path", + description: "The path to copy the document to. Maximum depth is 4 levels.", + optional: true, + }, + folderId: { + propDefinition: [ + papersign, + "folderId", + (c) => ({ + spaceId: c.spaceId, + }), + ], + optional: true, + }, + }, + async run({ $ }) { + const response = await this.papersign.duplicateDocument({ + documentId: this.documentId, + name: this.name, + spaceId: this.spaceId, + path: this.path, + folderId: this.folderId, + }); + + $.export("$summary", `Successfully copied document: ${response.results.document.name}`); + return response; + }, +}; diff --git a/components/papersign/actions/get-document/get-document.mjs b/components/papersign/actions/get-document/get-document.mjs new file mode 100644 index 0000000000000..c64fad6e2eaf7 --- /dev/null +++ b/components/papersign/actions/get-document/get-document.mjs @@ -0,0 +1,27 @@ +import papersign from "../../papersign.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "papersign-get-document", + name: "Get Document", + description: "Retrieve a document using a specified ID. [See the documentation](https://paperform.readme.io/reference/getpapersigndocument)", + version: "0.0.{{ts}}", + type: "action", + props: { + papersign, + documentId: { + propDefinition: [ + papersign, + "documentId", + ], + }, + }, + async run({ $ }) { + const response = await this.papersign.getDocument({ + documentId: this.documentId, + }); + + $.export("$summary", `Successfully retrieved document with ID: ${this.documentId}`); + return response; + }, +}; diff --git a/components/papersign/actions/send-document/send-document.mjs b/components/papersign/actions/send-document/send-document.mjs new file mode 100644 index 0000000000000..0c1d4ccb04341 --- /dev/null +++ b/components/papersign/actions/send-document/send-document.mjs @@ -0,0 +1,82 @@ +import papersign from "../../papersign.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "papersign-send-document", + name: "Send Document", + description: "Dispatches a document to a specified recipient. [See the documentation](https://paperform.readme.io/reference/papersignsenddocument)", + version: "0.0.1", + type: "action", + props: { + papersign, + documentId: { + propDefinition: [ + papersign, + "documentId", + ], + }, + expiration: { + type: "string", + label: "Expiration", + description: "The expiration date of the document. Must be at least 30 minutes in the future.", + optional: true, + }, + inviteMessage: { + type: "string", + label: "Invite Message", + description: "The message to include in the invitation email, up to 1000 characters.", + optional: true, + }, + fromUserEmail: { + type: "string", + label: "From User Email", + description: "The email address of a User on your team's account to send the document from.", + optional: true, + }, + documentRecipientEmails: { + type: "string[]", + label: "Document Recipient Emails", + description: "An array of recipient emails for the document.", + optional: true, + }, + automaticReminders: { + type: "object", + label: "Automatic Reminders", + description: "An object for setting automatic reminders.", + optional: true, + }, + signers: { + type: "string[]", + label: "Signers", + description: "An array of signer objects.", + optional: true, + }, + variables: { + type: "string[]", + label: "Variables", + description: "An array of variable objects.", + optional: true, + }, + copy: { + type: "boolean", + label: "Copy", + description: "Whether to copy before sending.", + optional: true, + }, + }, + async run({ $ }) { + const response = await this.papersign.sendDocument({ + documentId: this.documentId, + expiration: this.expiration, + inviteMessage: this.inviteMessage, + fromUserEmail: this.fromUserEmail, + documentRecipientEmails: this.documentRecipientEmails, + automaticReminders: this.automaticReminders, + signers: this.signers, + variables: this.variables, + copy: this.copy, + }); + $.export("$summary", `Document sent successfully with ID ${this.documentId}`); + return response; + }, +}; diff --git a/components/papersign/package.json b/components/papersign/package.json index 8e3df417d8ff5..0148563261ce2 100644 --- a/components/papersign/package.json +++ b/components/papersign/package.json @@ -12,4 +12,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/papersign/papersign.app.mjs b/components/papersign/papersign.app.mjs index d51851226db7e..ef12a5c1ab94e 100644 --- a/components/papersign/papersign.app.mjs +++ b/components/papersign/papersign.app.mjs @@ -1,11 +1,124 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "papersign", - propDefinitions: {}, + propDefinitions: { + documentId: { + type: "string", + label: "Document ID", + description: "Enter the ID of the Papersign document", + async options() { + const documents = await this.listDocuments(); + return documents.map((doc) => ({ + value: doc.id, + label: doc.name, + })); + }, + }, + spaceId: { + type: "string", + label: "Space ID", + description: "Enter the ID of the Papersign space", + async options() { + const spaces = await this.listSpaces(); + return spaces.map((space) => ({ + value: space.id, + label: space.name, + })); + }, + }, + folderId: { + type: "string", + label: "Folder ID", + description: "Enter the ID of the Papersign folder", + async options() { + const folders = await this.listFolders(); + return folders.map((folder) => ({ + value: folder.id, + label: folder.name, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.paperform.co/v1/papersign"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, method = "GET", path = "/", headers, ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + method, + url: this._baseUrl() + path, + headers: { + ...headers, + Authorization: `Bearer ${this.$auth.api_key}`, + }, + }); + }, + async listDocuments(opts = {}) { + return this._makeRequest({ + path: "/documents", + ...opts, + }); + }, + async listSpaces(opts = {}) { + return this._makeRequest({ + path: "/spaces", + ...opts, + }); + }, + async listFolders(opts = {}) { + const { spaceId } = opts; + return this._makeRequest({ + path: "/folders", + params: spaceId + ? { + space_id: spaceId, + } + : {}, + ...opts, + }); + }, + async duplicateDocument({ + documentId, name, spaceId, path, folderId, + }) { + return this._makeRequest({ + method: "POST", + path: `/documents/${documentId}/copy`, + data: { + name, + space_id: spaceId, + path, + folder_id: folderId, + }, + }); + }, + async getDocument({ documentId }) { + return this._makeRequest({ + path: `/documents/${documentId}`, + }); + }, + async sendDocument({ + documentId, expiration, inviteMessage, fromUserEmail, documentRecipientEmails, automaticReminders, signers, variables, copy, + }) { + return this._makeRequest({ + method: "POST", + path: `/documents/${documentId}/send`, + data: { + expiration, + invite_message: inviteMessage, + from_user_email: fromUserEmail, + document_recipient_emails: documentRecipientEmails, + automatic_reminders: automaticReminders, + signers, + variables, + copy, + }, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/papersign/sources/new-document-completed-instant/new-document-completed-instant.mjs b/components/papersign/sources/new-document-completed-instant/new-document-completed-instant.mjs new file mode 100644 index 0000000000000..4ab66d67044c6 --- /dev/null +++ b/components/papersign/sources/new-document-completed-instant/new-document-completed-instant.mjs @@ -0,0 +1,71 @@ +import papersign from "../../papersign.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "papersign-new-document-completed-instant", + name: "New Document Completed (Instant)", + description: "Emit new event when a document is completed, i.e., all signers have signed. [See the documentation](https://paperform.readme.io/reference/getting-started-1)", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + papersign, + http: { + type: "$.interface.http", + customResponse: false, + }, + db: "$.service.db", + }, + hooks: { + async deploy() { + const documents = await this.papersign.listDocuments(); + const completedDocs = documents.filter((doc) => doc.status === "completed"); + for (const doc of completedDocs) { + this.$emit(doc, { + id: doc.id, + summary: `Document ${doc.name} completed`, + ts: Date.parse(doc.updated_at), + }); + } + }, + async activate() { + const webhookData = { + name: "Document Completed Webhook", + target_url: this.http.endpoint, + triggers: [ + "document.completed", + ], + }; + const response = await axios(this, { + method: "POST", + url: `${this.papersign._baseUrl()}/webhooks`, + headers: { + Authorization: `Bearer ${this.papersign.$auth.api_key}`, + }, + data: webhookData, + }); + this.db.set("webhookId", response.webhook.id); + }, + async deactivate() { + const webhookId = this.db.get("webhookId"); + if (webhookId) { + await axios(this, { + method: "DELETE", + url: `${this.papersign._baseUrl()}/webhooks/${webhookId}`, + headers: { + Authorization: `Bearer ${this.papersign.$auth.api_key}`, + }, + }); + this.db.set("webhookId", null); + } + }, + }, + async run(event) { + const doc = event.body; + this.$emit(doc, { + id: doc.id, + summary: `Document ${doc.name} completed`, + ts: Date.parse(doc.updated_at), + }); + }, +}; diff --git a/components/papersign/sources/new-event-instant/new-event-instant.mjs b/components/papersign/sources/new-event-instant/new-event-instant.mjs new file mode 100644 index 0000000000000..77e120cac2a19 --- /dev/null +++ b/components/papersign/sources/new-event-instant/new-event-instant.mjs @@ -0,0 +1,71 @@ +import papersign from "../../papersign.app.mjs"; +import { axios } from "@pipedream/platform"; + +export default { + key: "papersign-new-event-instant", + name: "New Event in Papersign", + description: "Emit new event when any document or signer action occurs. [See the documentation](https://paperform.readme.io/reference/postpapersignfolderwebhooks)", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + papersign, + http: { + type: "$.interface.http", + customResponse: true, + }, + db: "$.service.db", + }, + hooks: { + async activate() { + const webhookName = "Pipedream Webhook"; + const triggers = [ + "document.sent", + "document.completed", + "document.cancelled", + "document.rejected", + "document.expired", + "signer.notified", + "signer.viewed", + "signer.consent_accepted", + "signer.nominated", + "signer.signed", + ]; + + const response = await this.papersign._makeRequest({ + method: "POST", + path: "/webhooks", + data: { + name: webhookName, + target_url: this.http.endpoint, + scope: "folder.all_descendants", + triggers, + }, + }); + + this.db.set("webhookId", response.id); + }, + async deactivate() { + const webhookId = this.db.get("webhookId"); + await this.papersign._makeRequest({ + method: "DELETE", + path: `/webhooks/${webhookId}`, + }); + }, + }, + async run(event) { + const body = event.body; + + // Respond to the webhook + this.http.respond({ + status: 200, + body: "OK", + }); + + this.$emit(body, { + id: body.id || body.document_id, + summary: `New event: ${body.name || body.document_name}`, + ts: Date.parse(body.timestamp) || Date.now(), + }); + }, +}; diff --git a/components/papersign/sources/new-signer-signed-instant/new-signer-signed-instant.mjs b/components/papersign/sources/new-signer-signed-instant/new-signer-signed-instant.mjs new file mode 100644 index 0000000000000..37f55caf1d735 --- /dev/null +++ b/components/papersign/sources/new-signer-signed-instant/new-signer-signed-instant.mjs @@ -0,0 +1,100 @@ +import papersign from "../../papersign.app.mjs"; +import crypto from "crypto"; +import { axios } from "@pipedream/platform"; + +export default { + key: "papersign-new-signer-signed-instant", + name: "New Signer Signed (Instant)", + description: "Emit new event when a signer signs a document. [See the documentation](https://paperform.readme.io/reference/postpapersignfolderwebhooks)", + version: "0.0.{{ts}}", + type: "source", + dedupe: "unique", + props: { + papersign, + http: { + type: "$.interface.http", + customResponse: true, + }, + db: "$.service.db", + }, + methods: { + _getWebhookId() { + return this.db.get("webhookId"); + }, + _setWebhookId(id) { + this.db.set("webhookId", id); + }, + }, + hooks: { + async deploy() { + const documents = await this.papersign.listDocuments({ + status: "signed", + }); + const recentDocuments = documents.slice(0, 50); + for (const doc of recentDocuments) { + this.$emit(doc, { + id: doc.id, + summary: `Document signed: ${doc.name}`, + ts: Date.parse(doc.signedAt), + }); + } + }, + async activate() { + const response = await axios(this, { + method: "POST", + url: `${this.papersign._baseUrl()}/folders/{folderId}/webhooks`, + headers: { + "Authorization": `Bearer ${this.papersign.$auth.api_key}`, + "Content-Type": "application/json", + }, + data: { + name: "New Signer Signed Webhook", + target_url: this.http.endpoint, + scope: "folder.all_descendants", + triggers: [ + "signer.signed", + ], + }, + }); + this._setWebhookId(response.webhook.id); + }, + async deactivate() { + const webhookId = this._getWebhookId(); + if (webhookId) { + await axios(this, { + method: "DELETE", + url: `${this.papersign._baseUrl()}/webhooks/${webhookId}`, + headers: { + Authorization: `Bearer ${this.papersign.$auth.api_key}`, + }, + }); + } + }, + }, + async run(event) { + const signature = event.headers["x-papersign-signature"]; + const secretKey = this.papersign.$auth.api_key; + const rawBody = JSON.stringify(event.body); + const computedSignature = crypto.createHmac("sha256", secretKey).update(rawBody) + .digest("base64"); + + if (computedSignature !== signature) { + this.http.respond({ + status: 401, + body: "Unauthorized", + }); + return; + } + + this.http.respond({ + status: 200, + body: "OK", + }); + + this.$emit(event.body, { + id: event.body.signerId, + summary: `Document signed by signer ${event.body.signerName}`, + ts: Date.parse(event.body.signedAt), + }); + }, +}; From 8046eef5e08a6f4e0ae41dd624469e4bc19a3971 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 25 Oct 2024 16:43:07 -0300 Subject: [PATCH 2/5] [Components] papersign #14412 Sources - New Event (Instant) - New Document Completed (Instant) - New Signer Signed (Instant) Actions - Copy Document - Get Document - Send Document --- .../actions/copy-document/copy-document.mjs | 25 ++-- .../actions/get-document/get-document.mjs | 4 +- .../actions/send-document/send-document.mjs | 67 ++++++--- components/papersign/common/constants.mjs | 12 ++ components/papersign/common/utils.mjs | 32 +++++ components/papersign/package.json | 5 +- components/papersign/papersign.app.mjs | 134 +++++++++--------- components/papersign/sources/common/base.mjs | 65 +++++++++ .../new-document-completed-instant.mjs | 75 ++-------- .../test-event.mjs | 10 ++ .../new-event-instant/new-event-instant.mjs | 64 ++------- .../sources/new-event-instant/test-event.mjs | 10 ++ .../new-signer-signed-instant.mjs | 102 ++----------- .../new-signer-signed-instant/test-event.mjs | 7 + 14 files changed, 313 insertions(+), 299 deletions(-) create mode 100644 components/papersign/common/constants.mjs create mode 100644 components/papersign/common/utils.mjs create mode 100644 components/papersign/sources/common/base.mjs create mode 100644 components/papersign/sources/new-document-completed-instant/test-event.mjs create mode 100644 components/papersign/sources/new-event-instant/test-event.mjs create mode 100644 components/papersign/sources/new-signer-signed-instant/test-event.mjs diff --git a/components/papersign/actions/copy-document/copy-document.mjs b/components/papersign/actions/copy-document/copy-document.mjs index b0ffa6868f7e3..19202f76c34a5 100644 --- a/components/papersign/actions/copy-document/copy-document.mjs +++ b/components/papersign/actions/copy-document/copy-document.mjs @@ -1,11 +1,10 @@ import papersign from "../../papersign.app.mjs"; -import { axios } from "@pipedream/platform"; export default { key: "papersign-copy-document", name: "Copy Document", description: "Duplicates a given document. [See the documentation](https://paperform.readme.io/reference/papersigncopydocument)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { papersign, @@ -31,27 +30,33 @@ export default { path: { type: "string", label: "Path", - description: "The path to copy the document to. Maximum depth is 4 levels.", + description: "The path to copy the document to. Maximum depth is 4 levels. Any missing folders will be created.", optional: true, }, folderId: { propDefinition: [ papersign, "folderId", - (c) => ({ - spaceId: c.spaceId, - }), ], optional: true, }, }, async run({ $ }) { + const data = {}; + if (this.folderId) { + data.folder_id = this.folderId; + } else { + data.space_id = this.spaceId; + data.path = this.path; + } + const response = await this.papersign.duplicateDocument({ + $, documentId: this.documentId, - name: this.name, - spaceId: this.spaceId, - path: this.path, - folderId: this.folderId, + data: { + ...data, + name: this.name, + }, }); $.export("$summary", `Successfully copied document: ${response.results.document.name}`); diff --git a/components/papersign/actions/get-document/get-document.mjs b/components/papersign/actions/get-document/get-document.mjs index c64fad6e2eaf7..d566fdd390518 100644 --- a/components/papersign/actions/get-document/get-document.mjs +++ b/components/papersign/actions/get-document/get-document.mjs @@ -1,11 +1,10 @@ import papersign from "../../papersign.app.mjs"; -import { axios } from "@pipedream/platform"; export default { key: "papersign-get-document", name: "Get Document", description: "Retrieve a document using a specified ID. [See the documentation](https://paperform.readme.io/reference/getpapersigndocument)", - version: "0.0.{{ts}}", + version: "0.0.1", type: "action", props: { papersign, @@ -18,6 +17,7 @@ export default { }, async run({ $ }) { const response = await this.papersign.getDocument({ + $, documentId: this.documentId, }); diff --git a/components/papersign/actions/send-document/send-document.mjs b/components/papersign/actions/send-document/send-document.mjs index 0c1d4ccb04341..1847319e6a907 100644 --- a/components/papersign/actions/send-document/send-document.mjs +++ b/components/papersign/actions/send-document/send-document.mjs @@ -1,5 +1,6 @@ +import { ConfigurationError } from "@pipedream/platform"; +import { parseObject } from "../../common/utils.mjs"; import papersign from "../../papersign.app.mjs"; -import { axios } from "@pipedream/platform"; export default { key: "papersign-send-document", @@ -18,7 +19,7 @@ export default { expiration: { type: "string", label: "Expiration", - description: "The expiration date of the document. Must be at least 30 minutes in the future.", + description: "The expiration date of the document. Must be at least 30 minutes in the future. **Format: YYYY-MM-DDTHH:MM:SS.SSSZ**", optional: true, }, inviteMessage: { @@ -39,22 +40,28 @@ export default { description: "An array of recipient emails for the document.", optional: true, }, - automaticReminders: { - type: "object", - label: "Automatic Reminders", - description: "An object for setting automatic reminders.", + firstAfterDays: { + type: "integer", + label: "Automatic Reminder - First After Days", + description: "The number of days after the document is sent to send the reminder.", + optional: true, + }, + followUpEveryDays: { + type: "integer", + label: "Automatic Reminder - Follow Up Every Days", + description: "The number of days to wait between reminders.", optional: true, }, signers: { type: "string[]", label: "Signers", - description: "An array of signer objects.", + description: "An array of objects of signers. **Object format: {\"key\": \"123\",\"name\": \"Jack Smith\",\"email\": \"signer@example.com\",\"phone\": \"123 456 7899\",\"job_title\": \"Account Manager\",\"company\": \"Explosive Startup\",\"custom_attributes\": [{\"key\": \"Relationship\",\"label\": \"Relationship to the company\",\"value\": \"CEO\"}]}**", optional: true, }, variables: { - type: "string[]", + type: "object", label: "Variables", - description: "An array of variable objects.", + description: "The key: value of the document variables.", optional: true, }, copy: { @@ -65,16 +72,42 @@ export default { }, }, async run({ $ }) { + if ( + (this.firstAfterDays && !this.followUpEveryDays) || + (!this.firstAfterDays && this.followUpEveryDays) + ) { + throw new ConfigurationError("You must fill in the fields 'First After Days' and 'Follow Up Every Days' or none of them"); + } + + const automaticReminders = {}; + if (this.firstAfterDays) { + automaticReminders.first_after_days = this.firstAfterDays; + automaticReminders.follow_up_every_days = this.followUpEveryDays; + } + + const variables = []; + if (this.variables) { + for (const key of Object.keys(parseObject(this.variables))) { + variables.push({ + key, + value: this.variables[key], + }); + } + } + const response = await this.papersign.sendDocument({ + $, documentId: this.documentId, - expiration: this.expiration, - inviteMessage: this.inviteMessage, - fromUserEmail: this.fromUserEmail, - documentRecipientEmails: this.documentRecipientEmails, - automaticReminders: this.automaticReminders, - signers: this.signers, - variables: this.variables, - copy: this.copy, + data: { + expiration: this.expiration, + inviteMessage: this.inviteMessage, + fromUserEmail: this.fromUserEmail, + documentRecipientEmails: parseObject(this.documentRecipientEmails), + automaticReminders, + signers: parseObject(this.signers), + variables, + copy: this.copy, + }, }); $.export("$summary", `Document sent successfully with ID ${this.documentId}`); return response; diff --git a/components/papersign/common/constants.mjs b/components/papersign/common/constants.mjs new file mode 100644 index 0000000000000..28a6656d208ad --- /dev/null +++ b/components/papersign/common/constants.mjs @@ -0,0 +1,12 @@ +export const LIMIT = 100; + +export const SCOPE_OPTIONS = [ + { + label: "Direct Children", + value: "folder.direct_children", + }, + { + label: "All Descendants", + value: "folder.all_descendants", + }, +]; diff --git a/components/papersign/common/utils.mjs b/components/papersign/common/utils.mjs new file mode 100644 index 0000000000000..9050833bcda0b --- /dev/null +++ b/components/papersign/common/utils.mjs @@ -0,0 +1,32 @@ +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 parseObject(item); + } + } + return item; + }); + } + if (typeof obj === "string") { + try { + return JSON.parse(obj); + } catch (e) { + return obj; + } + } + if (typeof obj === "object") { + for (const [ + key, + value, + ] of Object.entries(obj)) { + obj[key] = parseObject(value); + } + } + return obj; +}; diff --git a/components/papersign/package.json b/components/papersign/package.json index 0148563261ce2..656e518ce4d24 100644 --- a/components/papersign/package.json +++ b/components/papersign/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/papersign", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Papersign Components", "main": "papersign.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/components/papersign/papersign.app.mjs b/components/papersign/papersign.app.mjs index ef12a5c1ab94e..2f3e59c9ec6f2 100644 --- a/components/papersign/papersign.app.mjs +++ b/components/papersign/papersign.app.mjs @@ -1,4 +1,5 @@ import { axios } from "@pipedream/platform"; +import { LIMIT } from "./common/constants.mjs"; export default { type: "app", @@ -8,36 +9,33 @@ export default { type: "string", label: "Document ID", description: "Enter the ID of the Papersign document", - async options() { - const documents = await this.listDocuments(); - return documents.map((doc) => ({ - value: doc.id, - label: doc.name, - })); + async options({ page }) { + return await this.list({ + module: "documents", + page, + }); }, }, spaceId: { type: "string", label: "Space ID", description: "Enter the ID of the Papersign space", - async options() { - const spaces = await this.listSpaces(); - return spaces.map((space) => ({ - value: space.id, - label: space.name, - })); + async options({ page }) { + return await this.list({ + module: "spaces", + page, + }); }, }, folderId: { type: "string", label: "Folder ID", - description: "Enter the ID of the Papersign folder", - async options() { - const folders = await this.listFolders(); - return folders.map((folder) => ({ - value: folder.id, - label: folder.name, - })); + description: "Enter the ID of the Papersign folder. `If folder id is present, Space Id and Path will be ignored`.", + async options({ page }) { + return await this.list({ + module: "folders", + page, + }); }, }, }, @@ -45,79 +43,79 @@ export default { _baseUrl() { return "https://api.paperform.co/v1/papersign"; }, - async _makeRequest(opts = {}) { - const { - $ = this, method = "GET", path = "/", headers, ...otherOpts - } = opts; + _headers() { + return { + "Authorization": `Bearer ${this.$auth.access_token}`, + "accept": "application/json", + }; + }, + _makeRequest({ + $ = this, path, ...opts + }) { return axios($, { - ...otherOpts, - method, url: this._baseUrl() + path, - headers: { - ...headers, - Authorization: `Bearer ${this.$auth.api_key}`, - }, + headers: this._headers(), + ...opts, }); }, - async listDocuments(opts = {}) { - return this._makeRequest({ - path: "/documents", + async list({ + module, page, ...opts + }) { + const { results } = await this._makeRequest({ + path: `/${module}`, + params: { + limit: LIMIT, + skip: LIMIT * page, + }, ...opts, }); + + return results[module].map(({ + id: value, name: label, + }) => ({ + value, + label, + })); }, - async listSpaces(opts = {}) { + duplicateDocument({ + documentId, ...opts + }) { return this._makeRequest({ - path: "/spaces", + method: "POST", + path: `/documents/${documentId}/copy`, ...opts, }); }, - async listFolders(opts = {}) { - const { spaceId } = opts; + getDocument({ + documentId, ...opts + }) { return this._makeRequest({ - path: "/folders", - params: spaceId - ? { - space_id: spaceId, - } - : {}, + path: `/documents/${documentId}`, ...opts, }); }, - async duplicateDocument({ - documentId, name, spaceId, path, folderId, + sendDocument({ + documentId, ...opts }) { return this._makeRequest({ method: "POST", - path: `/documents/${documentId}/copy`, - data: { - name, - space_id: spaceId, - path, - folder_id: folderId, - }, + path: `/documents/${documentId}/send`, + ...opts, }); }, - async getDocument({ documentId }) { + createWebhook({ + folderId, ...opts + }) { return this._makeRequest({ - path: `/documents/${documentId}`, + method: "POST", + path: `/folders/${folderId}/webhooks`, + ...opts, }); }, - async sendDocument({ - documentId, expiration, inviteMessage, fromUserEmail, documentRecipientEmails, automaticReminders, signers, variables, copy, - }) { + deleteWebhook(hookId) { return this._makeRequest({ - method: "POST", - path: `/documents/${documentId}/send`, - data: { - expiration, - invite_message: inviteMessage, - from_user_email: fromUserEmail, - document_recipient_emails: documentRecipientEmails, - automatic_reminders: automaticReminders, - signers, - variables, - copy, - }, + method: "DELETE", + path: `/webhooks/${hookId}`, }); }, }, diff --git a/components/papersign/sources/common/base.mjs b/components/papersign/sources/common/base.mjs new file mode 100644 index 0000000000000..0855f52e7de43 --- /dev/null +++ b/components/papersign/sources/common/base.mjs @@ -0,0 +1,65 @@ +import { SCOPE_OPTIONS } from "../../common/constants.mjs"; +import papersign from "../../papersign.app.mjs"; + +export default { + props: { + papersign, + http: { + type: "$.interface.http", + customResponse: false, + }, + db: "$.service.db", + folderId: { + propDefinition: [ + papersign, + "folderId", + ], + }, + name: { + type: "string", + label: "Name", + description: "The name of the webhook.", + optional: true, + }, + scope: { + type: "string", + label: "Scope", + description: "The scope of the webhook", + options: SCOPE_OPTIONS, + optional: true, + }, + }, + methods: { + _setHookId(hookId) { + this.db.set("hookId", hookId); + }, + _getHookId() { + return this.db.get("hookId"); + }, + }, + hooks: { + async activate() { + const { results: { webhook } } = await this.papersign.createWebhook({ + folderId: this.folderId, + data: { + name: this.name, + target_url: this.http.endpoint, + scope: this.scope, + triggers: this.getTriggers(), + }, + }); + this._setHookId(webhook.id); + }, + async deactivate() { + const webhookId = this._getHookId("webhookId"); + await this.papersign.deleteWebhook(webhookId); + }, + }, + async run({ body }) { + this.$emit(body, { + id: body.id, + summary: this.getSummary(body), + ts: Date.parse(body.created_at), + }); + }, +}; diff --git a/components/papersign/sources/new-document-completed-instant/new-document-completed-instant.mjs b/components/papersign/sources/new-document-completed-instant/new-document-completed-instant.mjs index 4ab66d67044c6..40175d61ff4f1 100644 --- a/components/papersign/sources/new-document-completed-instant/new-document-completed-instant.mjs +++ b/components/papersign/sources/new-document-completed-instant/new-document-completed-instant.mjs @@ -1,71 +1,24 @@ -import papersign from "../../papersign.app.mjs"; -import { axios } from "@pipedream/platform"; +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; export default { + ...common, key: "papersign-new-document-completed-instant", name: "New Document Completed (Instant)", - description: "Emit new event when a document is completed, i.e., all signers have signed. [See the documentation](https://paperform.readme.io/reference/getting-started-1)", - version: "0.0.{{ts}}", + description: "Emit new event when a document is completed, i.e., all signers have signed.", + version: "0.0.1", type: "source", dedupe: "unique", - props: { - papersign, - http: { - type: "$.interface.http", - customResponse: false, + methods: { + ...common.methods, + getTriggers() { + return [ + "document.completed", + ]; }, - db: "$.service.db", - }, - hooks: { - async deploy() { - const documents = await this.papersign.listDocuments(); - const completedDocs = documents.filter((doc) => doc.status === "completed"); - for (const doc of completedDocs) { - this.$emit(doc, { - id: doc.id, - summary: `Document ${doc.name} completed`, - ts: Date.parse(doc.updated_at), - }); - } - }, - async activate() { - const webhookData = { - name: "Document Completed Webhook", - target_url: this.http.endpoint, - triggers: [ - "document.completed", - ], - }; - const response = await axios(this, { - method: "POST", - url: `${this.papersign._baseUrl()}/webhooks`, - headers: { - Authorization: `Bearer ${this.papersign.$auth.api_key}`, - }, - data: webhookData, - }); - this.db.set("webhookId", response.webhook.id); + getSummary(body) { + return `Document '${body.document_name}' completed`; }, - async deactivate() { - const webhookId = this.db.get("webhookId"); - if (webhookId) { - await axios(this, { - method: "DELETE", - url: `${this.papersign._baseUrl()}/webhooks/${webhookId}`, - headers: { - Authorization: `Bearer ${this.papersign.$auth.api_key}`, - }, - }); - this.db.set("webhookId", null); - } - }, - }, - async run(event) { - const doc = event.body; - this.$emit(doc, { - id: doc.id, - summary: `Document ${doc.name} completed`, - ts: Date.parse(doc.updated_at), - }); }, + sampleEmit, }; diff --git a/components/papersign/sources/new-document-completed-instant/test-event.mjs b/components/papersign/sources/new-document-completed-instant/test-event.mjs new file mode 100644 index 0000000000000..568316a81e779 --- /dev/null +++ b/components/papersign/sources/new-document-completed-instant/test-event.mjs @@ -0,0 +1,10 @@ +export default { + "id": "671ba9030af55bff3b7a8c00", + "document_id": "671ba9030af55bff3b7a8c00", + "document_name": "Document Name", + "type": "document.completed", + "data": { + "document_url": "https://sign.papersign.com/sign/671ba9030af55bff3b7a8c00/completed-document?expires=1737659429&signature=671ba9030af55bff3b7a8c00671ba9030af55bff3b7a8c00" + }, + "created_at": "2024-10-25T19:10:29+00:00" +} \ No newline at end of file diff --git a/components/papersign/sources/new-event-instant/new-event-instant.mjs b/components/papersign/sources/new-event-instant/new-event-instant.mjs index 77e120cac2a19..229f94dbabcf7 100644 --- a/components/papersign/sources/new-event-instant/new-event-instant.mjs +++ b/components/papersign/sources/new-event-instant/new-event-instant.mjs @@ -1,25 +1,18 @@ -import papersign from "../../papersign.app.mjs"; -import { axios } from "@pipedream/platform"; +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; export default { + ...common, key: "papersign-new-event-instant", - name: "New Event in Papersign", - description: "Emit new event when any document or signer action occurs. [See the documentation](https://paperform.readme.io/reference/postpapersignfolderwebhooks)", - version: "0.0.{{ts}}", + name: "New Event in Papersign (Instant)", + description: "Emit new event when any document or signer action occurs.", + version: "0.0.1", type: "source", dedupe: "unique", - props: { - papersign, - http: { - type: "$.interface.http", - customResponse: true, - }, - db: "$.service.db", - }, - hooks: { - async activate() { - const webhookName = "Pipedream Webhook"; - const triggers = [ + methods: { + ...common.methods, + getTriggers() { + return [ "document.sent", "document.completed", "document.cancelled", @@ -31,41 +24,10 @@ export default { "signer.nominated", "signer.signed", ]; - - const response = await this.papersign._makeRequest({ - method: "POST", - path: "/webhooks", - data: { - name: webhookName, - target_url: this.http.endpoint, - scope: "folder.all_descendants", - triggers, - }, - }); - - this.db.set("webhookId", response.id); }, - async deactivate() { - const webhookId = this.db.get("webhookId"); - await this.papersign._makeRequest({ - method: "DELETE", - path: `/webhooks/${webhookId}`, - }); + getSummary({ data }) { + return `New event: ${data.type}`; }, }, - async run(event) { - const body = event.body; - - // Respond to the webhook - this.http.respond({ - status: 200, - body: "OK", - }); - - this.$emit(body, { - id: body.id || body.document_id, - summary: `New event: ${body.name || body.document_name}`, - ts: Date.parse(body.timestamp) || Date.now(), - }); - }, + sampleEmit, }; diff --git a/components/papersign/sources/new-event-instant/test-event.mjs b/components/papersign/sources/new-event-instant/test-event.mjs new file mode 100644 index 0000000000000..568316a81e779 --- /dev/null +++ b/components/papersign/sources/new-event-instant/test-event.mjs @@ -0,0 +1,10 @@ +export default { + "id": "671ba9030af55bff3b7a8c00", + "document_id": "671ba9030af55bff3b7a8c00", + "document_name": "Document Name", + "type": "document.completed", + "data": { + "document_url": "https://sign.papersign.com/sign/671ba9030af55bff3b7a8c00/completed-document?expires=1737659429&signature=671ba9030af55bff3b7a8c00671ba9030af55bff3b7a8c00" + }, + "created_at": "2024-10-25T19:10:29+00:00" +} \ No newline at end of file diff --git a/components/papersign/sources/new-signer-signed-instant/new-signer-signed-instant.mjs b/components/papersign/sources/new-signer-signed-instant/new-signer-signed-instant.mjs index 37f55caf1d735..16b08fa730384 100644 --- a/components/papersign/sources/new-signer-signed-instant/new-signer-signed-instant.mjs +++ b/components/papersign/sources/new-signer-signed-instant/new-signer-signed-instant.mjs @@ -1,100 +1,24 @@ -import papersign from "../../papersign.app.mjs"; -import crypto from "crypto"; -import { axios } from "@pipedream/platform"; +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; export default { + ...common, key: "papersign-new-signer-signed-instant", name: "New Signer Signed (Instant)", - description: "Emit new event when a signer signs a document. [See the documentation](https://paperform.readme.io/reference/postpapersignfolderwebhooks)", - version: "0.0.{{ts}}", + description: "Emit new event when a signer signs a document.", + version: "0.0.1", type: "source", dedupe: "unique", - props: { - papersign, - http: { - type: "$.interface.http", - customResponse: true, - }, - db: "$.service.db", - }, methods: { - _getWebhookId() { - return this.db.get("webhookId"); - }, - _setWebhookId(id) { - this.db.set("webhookId", id); - }, - }, - hooks: { - async deploy() { - const documents = await this.papersign.listDocuments({ - status: "signed", - }); - const recentDocuments = documents.slice(0, 50); - for (const doc of recentDocuments) { - this.$emit(doc, { - id: doc.id, - summary: `Document signed: ${doc.name}`, - ts: Date.parse(doc.signedAt), - }); - } + ...common.methods, + getTriggers() { + return [ + "signer.signed", + ]; }, - async activate() { - const response = await axios(this, { - method: "POST", - url: `${this.papersign._baseUrl()}/folders/{folderId}/webhooks`, - headers: { - "Authorization": `Bearer ${this.papersign.$auth.api_key}`, - "Content-Type": "application/json", - }, - data: { - name: "New Signer Signed Webhook", - target_url: this.http.endpoint, - scope: "folder.all_descendants", - triggers: [ - "signer.signed", - ], - }, - }); - this._setWebhookId(response.webhook.id); + getSummary({ data }) { + return `Document signed by signer ${data.by.name}`; }, - async deactivate() { - const webhookId = this._getWebhookId(); - if (webhookId) { - await axios(this, { - method: "DELETE", - url: `${this.papersign._baseUrl()}/webhooks/${webhookId}`, - headers: { - Authorization: `Bearer ${this.papersign.$auth.api_key}`, - }, - }); - } - }, - }, - async run(event) { - const signature = event.headers["x-papersign-signature"]; - const secretKey = this.papersign.$auth.api_key; - const rawBody = JSON.stringify(event.body); - const computedSignature = crypto.createHmac("sha256", secretKey).update(rawBody) - .digest("base64"); - - if (computedSignature !== signature) { - this.http.respond({ - status: 401, - body: "Unauthorized", - }); - return; - } - - this.http.respond({ - status: 200, - body: "OK", - }); - - this.$emit(event.body, { - id: event.body.signerId, - summary: `Document signed by signer ${event.body.signerName}`, - ts: Date.parse(event.body.signedAt), - }); }, + sampleEmit, }; diff --git a/components/papersign/sources/new-signer-signed-instant/test-event.mjs b/components/papersign/sources/new-signer-signed-instant/test-event.mjs new file mode 100644 index 0000000000000..912a48198cf59 --- /dev/null +++ b/components/papersign/sources/new-signer-signed-instant/test-event.mjs @@ -0,0 +1,7 @@ +export default { + "project": "project_slug", + "translated": 100, + "resource": "resource_slug", + "event": "translation_completed", + "language": "lang_code" +} \ No newline at end of file From 224bed248a2b0567ea4cfdf8f3ad90e53d2b34a8 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 25 Oct 2024 16:49:09 -0300 Subject: [PATCH 3/5] pnpm update --- pnpm-lock.yaml | 107 +++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 52 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 095e5916ef9b9..dc84d165cab42 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7090,7 +7090,10 @@ importers: '@pipedream/platform': 3.0.3 components/papersign: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/papertrail: specifiers: {} @@ -13157,6 +13160,55 @@ packages: - aws-crt dev: false + /@aws-sdk/client-sso-oidc/3.600.0_tdq3komn4zwyd65w7klbptsu34: + resolution: {integrity: sha512-7+I8RWURGfzvChyNQSyj5/tKrqRbzRl7H+BnTOf/4Vsw1nFOi5ROhlhD4X/Y0QCTacxnaoNcIrqnY7uGGvVRzw==} + engines: {node: '>=16.0.0'} + dependencies: + '@aws-crypto/sha256-browser': 5.2.0 + '@aws-crypto/sha256-js': 5.2.0 + '@aws-sdk/client-sts': 3.600.0 + '@aws-sdk/core': 3.598.0 + '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 + '@aws-sdk/middleware-host-header': 3.598.0 + '@aws-sdk/middleware-logger': 3.598.0 + '@aws-sdk/middleware-recursion-detection': 3.598.0 + '@aws-sdk/middleware-user-agent': 3.598.0 + '@aws-sdk/region-config-resolver': 3.598.0 + '@aws-sdk/types': 3.598.0 + '@aws-sdk/util-endpoints': 3.598.0 + '@aws-sdk/util-user-agent-browser': 3.598.0 + '@aws-sdk/util-user-agent-node': 3.598.0 + '@smithy/config-resolver': 3.0.3 + '@smithy/core': 2.2.3 + '@smithy/fetch-http-handler': 3.2.1 + '@smithy/hash-node': 3.0.2 + '@smithy/invalid-dependency': 3.0.2 + '@smithy/middleware-content-length': 3.0.2 + '@smithy/middleware-endpoint': 3.0.4 + '@smithy/middleware-retry': 3.0.6 + '@smithy/middleware-serde': 3.0.3 + '@smithy/middleware-stack': 3.0.3 + '@smithy/node-config-provider': 3.1.3 + '@smithy/node-http-handler': 3.1.2 + '@smithy/protocol-http': 4.0.3 + '@smithy/smithy-client': 3.1.6 + '@smithy/types': 3.3.0 + '@smithy/url-parser': 3.0.3 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.6 + '@smithy/util-defaults-mode-node': 3.0.6 + '@smithy/util-endpoints': 2.0.3 + '@smithy/util-middleware': 3.0.3 + '@smithy/util-retry': 3.0.2 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.3 + transitivePeerDependencies: + - '@aws-sdk/client-sts' + - aws-crt + dev: false + /@aws-sdk/client-sso/3.423.0: resolution: {integrity: sha512-znIufHkwhCIePgaYciIs3x/+BpzR57CZzbCKHR9+oOvGyufEPPpUT5bFLvbwTgfiVkTjuk6sG/ES3U5Bc+xtrA==} engines: {node: '>=14.0.0'} @@ -13392,7 +13444,7 @@ packages: dependencies: '@aws-crypto/sha256-browser': 5.2.0 '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0 + '@aws-sdk/client-sso-oidc': 3.600.0_tdq3komn4zwyd65w7klbptsu34 '@aws-sdk/core': 3.598.0 '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 '@aws-sdk/middleware-host-header': 3.598.0 @@ -13434,55 +13486,6 @@ packages: - aws-crt dev: false - /@aws-sdk/client-sts/3.600.0_dseaa2p5u2yk67qiepewcq3hkq: - resolution: {integrity: sha512-KQG97B7LvTtTiGmjlrG1LRAY8wUvCQzrmZVV5bjrJ/1oXAU7DITYwVbSJeX9NWg6hDuSk0VE3MFwIXS2SvfLIA==} - engines: {node: '>=16.0.0'} - dependencies: - '@aws-crypto/sha256-browser': 5.2.0 - '@aws-crypto/sha256-js': 5.2.0 - '@aws-sdk/client-sso-oidc': 3.600.0 - '@aws-sdk/core': 3.598.0 - '@aws-sdk/credential-provider-node': 3.600.0_f7n47caigsrjd2lr2szmwfuee4 - '@aws-sdk/middleware-host-header': 3.598.0 - '@aws-sdk/middleware-logger': 3.598.0 - '@aws-sdk/middleware-recursion-detection': 3.598.0 - '@aws-sdk/middleware-user-agent': 3.598.0 - '@aws-sdk/region-config-resolver': 3.598.0 - '@aws-sdk/types': 3.598.0 - '@aws-sdk/util-endpoints': 3.598.0 - '@aws-sdk/util-user-agent-browser': 3.598.0 - '@aws-sdk/util-user-agent-node': 3.598.0 - '@smithy/config-resolver': 3.0.3 - '@smithy/core': 2.2.3 - '@smithy/fetch-http-handler': 3.2.1 - '@smithy/hash-node': 3.0.2 - '@smithy/invalid-dependency': 3.0.2 - '@smithy/middleware-content-length': 3.0.2 - '@smithy/middleware-endpoint': 3.0.4 - '@smithy/middleware-retry': 3.0.6 - '@smithy/middleware-serde': 3.0.3 - '@smithy/middleware-stack': 3.0.3 - '@smithy/node-config-provider': 3.1.3 - '@smithy/node-http-handler': 3.1.2 - '@smithy/protocol-http': 4.0.3 - '@smithy/smithy-client': 3.1.6 - '@smithy/types': 3.3.0 - '@smithy/url-parser': 3.0.3 - '@smithy/util-base64': 3.0.0 - '@smithy/util-body-length-browser': 3.0.0 - '@smithy/util-body-length-node': 3.0.0 - '@smithy/util-defaults-mode-browser': 3.0.6 - '@smithy/util-defaults-mode-node': 3.0.6 - '@smithy/util-endpoints': 2.0.3 - '@smithy/util-middleware': 3.0.3 - '@smithy/util-retry': 3.0.2 - '@smithy/util-utf8': 3.0.0 - tslib: 2.6.3 - transitivePeerDependencies: - - '@aws-sdk/client-sso-oidc' - - aws-crt - dev: false - /@aws-sdk/core/3.556.0: resolution: {integrity: sha512-vJaSaHw2kPQlo11j/Rzuz0gk1tEaKdz+2ser0f0qZ5vwFlANjt08m/frU17ctnVKC1s58bxpctO/1P894fHLrA==} engines: {node: '>=14.0.0'} @@ -17775,7 +17778,7 @@ packages: '@aws-sdk/client-sns': 3.423.0 '@aws-sdk/client-sqs': 3.423.0 '@aws-sdk/client-ssm': 3.423.0 - '@aws-sdk/client-sts': 3.600.0_dseaa2p5u2yk67qiepewcq3hkq + '@aws-sdk/client-sts': 3.600.0 '@aws-sdk/s3-request-presigner': 3.609.0 '@pipedream/helper_functions': 0.3.12 '@pipedream/platform': 1.6.6 From f1079e6bfdce352bad28ac44acf5ca31b53940c2 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Fri, 25 Oct 2024 17:15:51 -0300 Subject: [PATCH 4/5] fix method call --- components/papersign/sources/common/base.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/papersign/sources/common/base.mjs b/components/papersign/sources/common/base.mjs index 0855f52e7de43..315e081e23d59 100644 --- a/components/papersign/sources/common/base.mjs +++ b/components/papersign/sources/common/base.mjs @@ -51,7 +51,7 @@ export default { this._setHookId(webhook.id); }, async deactivate() { - const webhookId = this._getHookId("webhookId"); + const webhookId = this._getHookId(); await this.papersign.deleteWebhook(webhookId); }, }, From fa460cee40aa64e94a5e43286bb722dcf69db20c Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Wed, 30 Oct 2024 14:58:55 -0300 Subject: [PATCH 5/5] remove optional true from scope --- components/papersign/sources/common/base.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/papersign/sources/common/base.mjs b/components/papersign/sources/common/base.mjs index 315e081e23d59..3fcd824eb6ed5 100644 --- a/components/papersign/sources/common/base.mjs +++ b/components/papersign/sources/common/base.mjs @@ -26,7 +26,6 @@ export default { label: "Scope", description: "The scope of the webhook", options: SCOPE_OPTIONS, - optional: true, }, }, methods: {