Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
37ca887
Added Form.taxi
wrktbiz Aug 27, 2025
2670165
Update components/form_taxi/package.json
wrktbiz Aug 28, 2025
1321742
Update components/form_taxi/sources/new-form-submission/new-form-subm…
wrktbiz Aug 28, 2025
ee654b5
Update package.json
wrktbiz Aug 28, 2025
efcedd7
Update new-form-submission.mjs
wrktbiz Aug 28, 2025
1271a44
Merge branch 'master' into master
wrktbiz Aug 28, 2025
a3a51c0
Merge branch 'master' into master
GTFalcao Nov 3, 2025
d35a65d
Apply suggestion from @lcaresia
wrktbiz Nov 5, 2025
6ef0cdd
Apply suggestion from @lcaresia
wrktbiz Nov 5, 2025
daa2845
Merge branch 'master' into master
wrktbiz Nov 6, 2025
99cca8f
Update Form.taxi component with latest code revisions
wrktbiz Nov 6, 2025
f4d3504
Update Form.taxi Pipedream source with latest version
wrktbiz Nov 6, 2025
5f3b6ac
Update Form.taxi Pipedream source with latest version
wrktbiz Nov 6, 2025
880cd3f
Update Form.taxi Pipedream source with latest version
wrktbiz Nov 7, 2025
470b004
Update Form.taxi Pipedream source with latest version
wrktbiz Nov 7, 2025
cc4a1e1
Update components/form_taxi/sources/new-form-submission/new-form-subm…
wrktbiz Nov 11, 2025
bda8825
Merge branch 'master' into master
lcaresia Nov 11, 2025
64c791d
Update components/form_taxi/sources/common/base.mjs
wrktbiz Nov 11, 2025
318ba9b
Update components/form_taxi/sources/common/base.mjs
wrktbiz Nov 11, 2025
18a7e1c
Update components/form_taxi/sources/common/base.mjs
wrktbiz Nov 11, 2025
bb50890
Update components/form_taxi/sources/common/base.mjs
wrktbiz Nov 11, 2025
b757694
Update components/form_taxi/sources/common/base.mjs
wrktbiz Nov 11, 2025
9ccccb3
Update components/form_taxi/form_taxi.app.mjs
wrktbiz Nov 11, 2025
df0a156
Update components/form_taxi/sources/common/base.mjs
wrktbiz Nov 11, 2025
0482fcc
Update components/form_taxi/package.json
wrktbiz Nov 11, 2025
419e694
Update Form.taxi Pipedream source with latest version
wrktbiz Nov 11, 2025
d1aa9ff
Update Form.taxi Pipedream source with latest version
wrktbiz Nov 12, 2025
daa368d
Update Form.taxi Pipedream source with latest version
wrktbiz Nov 12, 2025
8c5294b
Merge branch 'master' into master
lcaresia Nov 18, 2025
0d35ce3
Update Form.taxi component with latest code changes
wrktbiz Nov 18, 2025
7c94805
update pnpm-lock
GTFalcao Nov 18, 2025
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
7 changes: 7 additions & 0 deletions components/form_taxi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Overview

Form.taxi provides a simple and secure way to handle form submissions without writing any server-side code. With Form.taxi, you can quickly connect your HTML forms and deliver submissions or integrate them into your existing workflows. By using Pipedream, you can automate actions in response to new form submissions—such as storing data, sending notifications, or connecting with third-party apps—making it easy to streamline processes and boost productivity.

# Troubleshooting

If you have issues with this integration, please reach out at [[email protected]](mailto:[email protected]).
6 changes: 6 additions & 0 deletions components/form_taxi/form_taxi.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
type: "app",
app: "form_taxi",
name: "Form.taxi",
description: "Receive submissions from Form.taxi",
}
22 changes: 22 additions & 0 deletions components/form_taxi/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@pipedream/form_taxi",
"version": "0.0.1",
"description": "Pipedream Form.taxi Components",
"main": "form_taxi.app.mjs",
"keywords": [
"pipedream",
"form_taxi"
],
"homepage": "https://pipedream.com/apps/form_taxi",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"dependencies": {
"@pipedream/platform": "^3.1.0"
},
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"package": "^1.0.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
import form_taxi from "../../form_taxi.app.mjs";
import axios from "axios";

export default {
type: "source",
name: "New Form Submission",
key: "form_taxi-new-form-submission",
version: "0.0.1",
description: "Emit new event when Form.taxi receives a new form submission. [About Form.taxi](https://form.taxi/en/backend)",

props: {
db: { type: "$.service.db", label: "Database" },
http: { type: "$.interface.http", label: "HTTP Interface", customResponse: true },
alert: {
type: "alert",
alertType: "info",
content: "Open the [Form.taxi Panel](https://form.taxi/panel/forms) to retrieve the Form Code and API Key. These are displayed in the form settings under Information.",
},
form_code: {
type: "string",
label: "Form Code",
},
form_taxi_api_key: {
type: "string",
label: "API Key",
secret: true,
},
},

dedupe: "unique",

methods: {
api() {
return axios.create({
headers: {
"Api-Key": this.form_taxi_api_key,
"Content-Type": "application/json",
},
timeout: 10000,
validateStatus: () => true,
});
},

subscriptionBaseUrl() {
return `https://form.taxi/int/pipedream/webhook_subscription/${encodeURIComponent(this.form_code)}`;
},

async registerWebhook() {
const targetUrl = this.http.endpoint;
const resp = await this.api().post(this.subscriptionBaseUrl(), { hook_url: targetUrl });

if (resp.status < 200 || resp.status >= 300) {
const msg = resp?.data?.message || "Unknown error";
throw new Error(
`Error (${resp.status}): ${msg}`
);
}

const id = resp?.data?.id;
const expires_at = resp?.data?.expires_at; // ISO-8601 erwartet

if (!id) throw new Error(`Response without id!`);
if (!expires_at) throw new Error(`Response without Expire-Date!`);

await this.db.set("webhookId", id);
await this.db.set("webhookExpiresAt", expires_at);

return resp.data;
},

async deleteWebhookById(hookId) {
if (!hookId) return;
const url = `${this.subscriptionBaseUrl()}?hook_id=${encodeURIComponent(hookId)}`;
const resp = await this.api().delete(url);
if (resp.status >= 400) {
const msg = resp?.data?.message || "Unknown error";
console.warn(`Webhook-Delete fehlgeschlagen: ${resp.status} ${msg}`);
}
},

async deleteWebhook() {
const webhookId = await this.db.get("webhookId");
if (!webhookId) return;
await this.deleteWebhookById(webhookId);
},

// ---- Ablaufprüfung & Erneuerung ----
msUntilExpiry(expiresAtIso) {
if (!expiresAtIso) return null;
const expMs = Date.parse(expiresAtIso);
if (Number.isNaN(expMs)) return null;
return expMs - Date.now();
},

async ensureWebhookFresh() {
const webhookId = await this.db.get("webhookId");
const expiresAt = await this.db.get("webhookExpiresAt");

// Wenn wir kein Ablaufdatum kennen, machen wir nichts (oder könnten aggressiv erneuern).
const msLeft = this.msUntilExpiry(expiresAt);
const windowMs = 60 * 60 * 1000; // 60 Minuten

// Erneuerungsbedingungen:
// - kein webhookId (unerwartet) ODER
// - kein expiresAt bekannt ODER
// - bereits abgelaufen ODER
// - Restlaufzeit < renewal window
const shouldRenew =
!webhookId ||
!msLeft ||
msLeft <= 0 ||
msLeft < windowMs;

if (!shouldRenew) return;

try {
// Neu registrieren
const oldId = webhookId;
const res = await this.registerWebhook();

// Alten Hook bereinigen (best effort), wenn wir eine neue ID haben
if (oldId && res?.id && res.id !== oldId) {
await this.deleteWebhookById(oldId);
}

console.log(
`Webhook erstellt/erneuert. Neue ID: ${res?.id || "unbekannt"}, läuft bis: ${res?.expires_at || "unbekannt"}`
);
} catch (err) {
console.error(`Automatische Erneuerung fehlgeschlagen: ${err.message}`);
}
},

eventIdFromBody(body) {
return (
body?._id ||
`${Date.now()}-${Math.random().toString(36).slice(2)}`
);
},

async fetchAndEmitSamples() {
try {
const resp = await this.api().get(this.subscriptionBaseUrl());
if (resp.status < 200 || resp.status >= 300) {
const msg = resp?.data?.message || "Unknown error";
console.warn(`Sample-GET fehlgeschlagen (${resp.status}): ${msg}`);
return;
}

const data = resp.data;
if (!data) {
console.warn("Sample-GET: leere Antwort");
return;
}

const emitOne = (obj) => {
const id = this.eventIdFromBody(obj || {}) || `sample-${Date.now()}`;
const ts =
(obj?.created_at && Date.parse(obj.created_at)) ||
Date.now();

// Wir packen die Daten in das gleiche Format wie echte Events
this.$emit(
{
headers: { "x-sample": "true" },
query: {},
body: obj,
received_at: new Date().toISOString(),
source: "Form.taxi",
sample: true,
},
{
id,
summary: `Sample submission`,
ts,
}
);
};

if (Array.isArray(data)) {
data.forEach(emitOne);
} else if (typeof data === "object") {
emitOne(data);
} else {
console.warn("Sample-GET: unbekanntes Format", data);
}
} catch (err) {
console.error(`Sample-GET Exception: ${err.message}`);
}
},
},

hooks: {
async deploy() {

// Unmittelbar Sample-Daten laden und emittieren
await this.fetchAndEmitSamples();
},
async activate() {

// Webhook frisch registrieren
const res = await this.registerWebhook();
console.log("Webhook registriert:", res);
},
async deactivate() {
try {
await this.deleteWebhook();
} catch (err) {
console.warn("Fehler beim Entfernen des Webhooks:", err.message);
}
},
},

async run(event) {
// Vor der Verarbeitung prüfen, ob der Hook bald abläuft und ggf. erneuern
await this.ensureWebhookFresh();

// Sofort ACK an Form.taxi
await this.http.respond({
status: 200,
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ ok: true }),
});

// Event emittieren
const id = this.eventIdFromBody(event.body || {});
const summary = `Form Submission ID: ${id}`;
const ts =
(event.body?.created_at && Date.parse(event.body.created_at)) || Date.now();

const payload = {
headers: event.headers,
query: event.query,
body: event.body,
received_at: new Date().toISOString(),
source: "Form.taxi",
};

this.$emit(payload, {
id,
summary: summary,
ts,
});
},
};