From adcbf53a1cc7b704b9c29d143c02b39225ca69b8 Mon Sep 17 00:00:00 2001 From: Luan Cazarine Date: Mon, 24 Nov 2025 16:33:45 -0500 Subject: [PATCH 1/3] Update Paperform Component: Bump version to 0.2.0, add webhook management methods, and introduce new sources for form submissions and partial submissions. --- components/paperform/package.json | 2 +- components/paperform/paperform.app.mjs | 15 +++++ components/paperform/sources/common/base.mjs | 47 ++++++++++++++++ .../new-form-submission-instant.mjs | 24 ++++++++ .../test-event.mjs | 56 +++++++++++++++++++ .../new-partial-form-submission-instant.mjs | 24 ++++++++ .../test-event.mjs | 27 +++++++++ .../sources/new-submission/new-submission.mjs | 4 +- 8 files changed, 196 insertions(+), 3 deletions(-) create mode 100644 components/paperform/sources/common/base.mjs create mode 100644 components/paperform/sources/new-form-submission-instant/new-form-submission-instant.mjs create mode 100644 components/paperform/sources/new-form-submission-instant/test-event.mjs create mode 100644 components/paperform/sources/new-partial-form-submission-instant/new-partial-form-submission-instant.mjs create mode 100644 components/paperform/sources/new-partial-form-submission-instant/test-event.mjs diff --git a/components/paperform/package.json b/components/paperform/package.json index cd5ef9ff8e3ee..a5731f62b94e6 100644 --- a/components/paperform/package.json +++ b/components/paperform/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/paperform", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream PaperForm Components", "main": "paperform.app.mjs", "keywords": [ diff --git a/components/paperform/paperform.app.mjs b/components/paperform/paperform.app.mjs index fe4ba95739c90..0e66e9074a415 100644 --- a/components/paperform/paperform.app.mjs +++ b/components/paperform/paperform.app.mjs @@ -49,6 +49,21 @@ export default { ...opts, }); }, + createHook({ + formId, ...opts + }) { + return this._makeRequest({ + path: `/forms/${formId}/webhooks`, + method: "POST", + ...opts, + }); + }, + deleteHook(hookId) { + return this._makeRequest({ + path: `/webhooks/${hookId}`, + method: "DELETE", + }); + }, listSubmissions({ formId, ...opts }) { diff --git a/components/paperform/sources/common/base.mjs b/components/paperform/sources/common/base.mjs new file mode 100644 index 0000000000000..ab572aa147a3e --- /dev/null +++ b/components/paperform/sources/common/base.mjs @@ -0,0 +1,47 @@ +import paperform from "../../paperform.app.mjs"; + +export default { + props: { + paperform, + db: "$.service.db", + http: "$.interface.http", + formId: { + propDefinition: [ + paperform, + "formId", + ], + }, + }, + methods: { + _setWebhookId(id) { + this.db.set("webhookId", id); + }, + _getWebhookId() { + return this.db.get("webhookId"); + }, + }, + hooks: { + async activate() { + const { results: { webhook } } = await this.paperform.createHook({ + formId: this.formId, + data: { + target_url: this.http.endpoint, + triggers: this.getTriggers(), + }, + }); + this._setWebhookId(webhook.id); + }, + async deactivate() { + const webhookId = this._getWebhookId(); + await this.paperform.deleteHook(webhookId); + }, + }, + async run({ body }) { + const ts = Date.parse(body.created_at || new Date()); + this.$emit(body, { + id: body.submission_id || ts, + summary: this.getSummary(body), + ts, + }); + }, +}; diff --git a/components/paperform/sources/new-form-submission-instant/new-form-submission-instant.mjs b/components/paperform/sources/new-form-submission-instant/new-form-submission-instant.mjs new file mode 100644 index 0000000000000..079bc3589d736 --- /dev/null +++ b/components/paperform/sources/new-form-submission-instant/new-form-submission-instant.mjs @@ -0,0 +1,24 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "paperform-new-form-submission-instant", + name: "New Form Submission (Instant)", + description: "Emit new event when a form is submitted.", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getTriggers() { + return [ + "submission", + ]; + }, + getSummary({ submission_id: id }) { + return `Form submission with ID ${id} received`; + }, + }, + sampleEmit, +}; diff --git a/components/paperform/sources/new-form-submission-instant/test-event.mjs b/components/paperform/sources/new-form-submission-instant/test-event.mjs new file mode 100644 index 0000000000000..3ef9b34ee0964 --- /dev/null +++ b/components/paperform/sources/new-form-submission-instant/test-event.mjs @@ -0,0 +1,56 @@ +export default { + "data": [ + { + "title": "How many paragraphs?", + "description": null, + "type": "dropdown", + "key": "f8quc", + "custom_key": null, + "value": "4" + }, + { + "title": "Style of paragraph", + "description": null, + "type": "dropdown", + "key": "aluau", + "custom_key": null, + "value": "Medium" + } + ], + "form_id": "6924bccaef650f4f4c0aabc7", + "slug": "q59luyjh", + "submission_id": "6924ca9a37b747c7b8025ffc", + "created_at": "2025-11-24 21:14:02", + "ip_address": "71.58.9.130", + "charge": { + "products": [], + "summary": "", + "discount": 0, + "discounted_subscriptions": [], + "coupon": false, + "total": 0, + "total_cents": 0, + "tax": 0, + "tax_percentage": 0, + "processing_fee": 0, + "authorize": null, + "receipt_email": false + }, + "team_id": 505160, + "trigger": "submission", + "device": { + "type": "desktop", + "device": "WebKit", + "platform": "Windows", + "browser": "Edge", + "embedded": false, + "url": "https://q59luyjh.paperform.co/", + "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0", + "utm_source": null, + "utm_medium": null, + "utm_campaign": null, + "utm_term": null, + "utm_content": null, + "ip_address": "12.34.56.789" + } +} \ No newline at end of file diff --git a/components/paperform/sources/new-partial-form-submission-instant/new-partial-form-submission-instant.mjs b/components/paperform/sources/new-partial-form-submission-instant/new-partial-form-submission-instant.mjs new file mode 100644 index 0000000000000..11e1fe9a2295c --- /dev/null +++ b/components/paperform/sources/new-partial-form-submission-instant/new-partial-form-submission-instant.mjs @@ -0,0 +1,24 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "paperform-new-partial-form-submission-instant", + name: "New Partial Form Submission (Instant)", + description: "Emit new event when a form is partially submitted.", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getTriggers() { + return [ + "partial_submission", + ]; + }, + getSummary() { + return "A new partial form submission was received"; + }, + }, + sampleEmit, +}; diff --git a/components/paperform/sources/new-partial-form-submission-instant/test-event.mjs b/components/paperform/sources/new-partial-form-submission-instant/test-event.mjs new file mode 100644 index 0000000000000..81cda20026127 --- /dev/null +++ b/components/paperform/sources/new-partial-form-submission-instant/test-event.mjs @@ -0,0 +1,27 @@ +export default { + "data": [ + { + "title": "How many paragraphs?", + "description": null, + "type": "dropdown", + "key": "f8quc", + "custom_key": null, + "value": "3" + }, + { + "title": "Style of paragraph", + "description": null, + "type": "dropdown", + "key": "aluau", + "custom_key": null, + "value": "Long" + } + ], + "form_id": "6924bccaef650f4f4c0aabc7", + "slug": "q59luyjh", + "submission_id": null, + "created_at": null, + "ip_address": null, + "charge": null, + "team_id": 505160 +} \ No newline at end of file diff --git a/components/paperform/sources/new-submission/new-submission.mjs b/components/paperform/sources/new-submission/new-submission.mjs index 2ce46137114c6..c4bfebff64bc0 100644 --- a/components/paperform/sources/new-submission/new-submission.mjs +++ b/components/paperform/sources/new-submission/new-submission.mjs @@ -1,11 +1,11 @@ -import paperform from "../../paperform.app.mjs"; import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import paperform from "../../paperform.app.mjs"; export default { key: "paperform-new-submission", name: "New Submission", description: "Emit new event when a new submission is made on the specified form in Paperform. [See the documentation](https://paperform.readme.io/reference/listformsubmissions)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { From c2127a2e585bb01b3b2ff7a460fd9314543f5c2c Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 24 Nov 2025 19:20:07 -0500 Subject: [PATCH 2/3] protect against incoming events not from webhook --- components/paperform/sources/common/base.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/paperform/sources/common/base.mjs b/components/paperform/sources/common/base.mjs index ab572aa147a3e..7a5bf458d8f80 100644 --- a/components/paperform/sources/common/base.mjs +++ b/components/paperform/sources/common/base.mjs @@ -37,6 +37,9 @@ export default { }, }, async run({ body }) { + if (!body.form_id) { + return; + } const ts = Date.parse(body.created_at || new Date()); this.$emit(body, { id: body.submission_id || ts, From 28c906245d652420df7fa0d63b79c2cf01bdcee7 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 24 Nov 2025 19:21:48 -0500 Subject: [PATCH 3/3] add doc links --- .../new-form-submission-instant/new-form-submission-instant.mjs | 2 +- .../new-partial-form-submission-instant.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/paperform/sources/new-form-submission-instant/new-form-submission-instant.mjs b/components/paperform/sources/new-form-submission-instant/new-form-submission-instant.mjs index 079bc3589d736..5ca1eb802abf6 100644 --- a/components/paperform/sources/new-form-submission-instant/new-form-submission-instant.mjs +++ b/components/paperform/sources/new-form-submission-instant/new-form-submission-instant.mjs @@ -5,7 +5,7 @@ export default { ...common, key: "paperform-new-form-submission-instant", name: "New Form Submission (Instant)", - description: "Emit new event when a form is submitted.", + description: "Emit new event when a form is submitted. [See the documentation](https://paperform.readme.io/reference/createformwebhook)", version: "0.0.1", type: "source", dedupe: "unique", diff --git a/components/paperform/sources/new-partial-form-submission-instant/new-partial-form-submission-instant.mjs b/components/paperform/sources/new-partial-form-submission-instant/new-partial-form-submission-instant.mjs index 11e1fe9a2295c..0ac605ad5d4be 100644 --- a/components/paperform/sources/new-partial-form-submission-instant/new-partial-form-submission-instant.mjs +++ b/components/paperform/sources/new-partial-form-submission-instant/new-partial-form-submission-instant.mjs @@ -5,7 +5,7 @@ export default { ...common, key: "paperform-new-partial-form-submission-instant", name: "New Partial Form Submission (Instant)", - description: "Emit new event when a form is partially submitted.", + description: "Emit new event when a form is partially submitted. [See the documentation](https://paperform.readme.io/reference/createformwebhook)", version: "0.0.1", type: "source", dedupe: "unique",