diff --git a/components/formaloo/actions/common/utils.mjs b/components/formaloo/actions/common/utils.mjs deleted file mode 100644 index efed6d1d184a1..0000000000000 --- a/components/formaloo/actions/common/utils.mjs +++ /dev/null @@ -1,23 +0,0 @@ -export const prepareData = (data) => { - const responseObj = {}; - for (const [ - key, - value, - ] of Object.entries(data)) { - const el = getKey(key); - responseObj[el] = value; - } - return responseObj; -}; - -const getKey = (key) => { - const elements = { - fullName: "full_name", - firstName: "first_name", - lastName: "last_name", - phoneNumber: "phone_number", - customerData: "customer_data", - }; - - return elements[key] || key; -}; diff --git a/components/formaloo/actions/create-customer/create-customer.mjs b/components/formaloo/actions/create-customer/create-customer.mjs deleted file mode 100644 index 9cf038b00dcbd..0000000000000 --- a/components/formaloo/actions/create-customer/create-customer.mjs +++ /dev/null @@ -1,177 +0,0 @@ -import formaloo from "../../formaloo.app.mjs"; - -export default { - key: "formaloo-create-customer", - name: "Create Customer", - version: "0.0.1", - description: "Create a new customer on the current business. [See the documentation](https://www.formaloo.com/en/developers/)", - type: "action", - props: { - formaloo, - fullName: { - propDefinition: [ - formaloo, - "fullName", - ], - optional: true, - }, - firstName: { - propDefinition: [ - formaloo, - "firstName", - ], - optional: true, - }, - lastName: { - propDefinition: [ - formaloo, - "lastName", - ], - optional: true, - }, - username: { - propDefinition: [ - formaloo, - "username", - ], - }, - email: { - propDefinition: [ - formaloo, - "email", - ], - }, - phoneNumber: { - propDefinition: [ - formaloo, - "phoneNumber", - ], - }, - numberOfTags: { - propDefinition: [ - formaloo, - "numberOfTags", - ], - optional: true, - reloadProps: true, - }, - score: { - propDefinition: [ - formaloo, - "score", - ], - optional: true, - }, - countrySlug: { - propDefinition: [ - formaloo, - "countrySlug", - ], - optional: true, - }, - stateSlug: { - propDefinition: [ - formaloo, - "stateSlug", - ({ countrySlug }) => ({ - countrySlug, - }), - ], - optional: true, - }, - city: { - propDefinition: [ - formaloo, - "city", - ({ stateSlug }) => ({ - stateSlug, - }), - ], - optional: true, - }, - language: { - propDefinition: [ - formaloo, - "language", - ], - optional: true, - }, - customerData: { - propDefinition: [ - formaloo, - "customerData", - ], - optional: true, - }, - }, - async additionalProps() { - return Array.from({ - length: this.numberOfTags, - }).reduce((acc, _, index) => { - const pos = index + 1; - - return { - ...acc, - [`tagSlug-${pos}`]: { - type: "string", - label: `Tag ${pos}`, - description: "The tag you want to add.", - options: async ({ page }) => { - const { data } = await this.formaloo.listTags({ - params: { - page: page + 1, - }, - }); - return data?.tags.map(({ - slug: value, title: label, - }) => ({ - label, - value, - })); - }, - }, - }; - }, {}); - }, - methods: { - getTag(index) { - const pos = index + 1; - const { [`tagSlug-${pos}`]: slug } = this; - return { - slug, - }; - }, - getTags() { - return Array.from({ - length: this.numberOfTags, - }).map((_, index) => this.getTag(index)); - }, - }, - async run({ $ }) { - const { - formaloo, - fullName, - firstName, - lastName, - phoneNumber, - customerData, - ...data - } = this; - - const response = await formaloo.createCustomer({ - $, - data: { - ...data, - full_name: fullName, - first_name: firstName, - last_name: lastName, - phone_number: phoneNumber, - customer_data: customerData, - tags: this.getTags(), - }, - }); - - $.export("$summary", `A new customer with Id: ${response?.data?.customer?.slug} was successfully created!`); - return response; - }, -}; diff --git a/components/formaloo/actions/update-customer/update-customer.mjs b/components/formaloo/actions/update-customer/update-customer.mjs deleted file mode 100644 index a25d4e3f3efb8..0000000000000 --- a/components/formaloo/actions/update-customer/update-customer.mjs +++ /dev/null @@ -1,177 +0,0 @@ -import formaloo from "../../formaloo.app.mjs"; -import { prepareData } from "../common/utils.mjs"; - -export default { - key: "formaloo-update-customer", - name: "Update Customer", - version: "0.0.1", - description: "Update a specific customer. [See the documentation](https://www.formaloo.com/en/developers/)", - type: "action", - props: { - formaloo, - customerId: { - propDefinition: [ - formaloo, - "customerId", - ], - }, - fullName: { - propDefinition: [ - formaloo, - "fullName", - ], - optional: true, - }, - firstName: { - propDefinition: [ - formaloo, - "firstName", - ], - optional: true, - }, - lastName: { - propDefinition: [ - formaloo, - "lastName", - ], - optional: true, - }, - username: { - propDefinition: [ - formaloo, - "username", - ], - }, - email: { - propDefinition: [ - formaloo, - "email", - ], - }, - phoneNumber: { - propDefinition: [ - formaloo, - "phoneNumber", - ], - }, - numberOfTags: { - propDefinition: [ - formaloo, - "numberOfTags", - ], - optional: true, - reloadProps: true, - }, - score: { - propDefinition: [ - formaloo, - "score", - ], - optional: true, - }, - countrySlug: { - propDefinition: [ - formaloo, - "countrySlug", - ], - optional: true, - }, - stateSlug: { - propDefinition: [ - formaloo, - "stateSlug", - ({ countrySlug }) => ({ - countrySlug, - }), - ], - optional: true, - }, - city: { - propDefinition: [ - formaloo, - "city", - ({ stateSlug }) => ({ - stateSlug, - }), - ], - optional: true, - }, - language: { - propDefinition: [ - formaloo, - "language", - ], - optional: true, - }, - customerData: { - propDefinition: [ - formaloo, - "customerData", - ], - optional: true, - }, - }, - async additionalProps() { - return Array.from({ - length: this.numberOfTags, - }).reduce((acc, _, index) => { - const pos = index + 1; - - return { - ...acc, - [`tagSlug-${pos}`]: { - type: "string", - label: `Tag ${pos}`, - description: "The tag you want to add.", - options: async ({ page }) => { - const { data } = await this.formaloo.listTags({ - params: { - page: page + 1, - }, - }); - return data?.tags.map(({ - slug: value, title: label, - }) => ({ - label, - value, - })); - }, - }, - }; - }, {}); - }, - methods: { - getTag(index) { - const pos = index + 1; - const { [`tagSlug-${pos}`]: slug } = this; - return { - slug, - }; - }, - getTags() { - return Array.from({ - length: this.numberOfTags, - }).map((_, index) => this.getTag(index)); - }, - }, - async run({ $ }) { - const { - formaloo, - customerId, - ...data - } = this; - - const body = prepareData(data); - const tags = this.getTags(); - if (tags.length) body.tags = tags; - - const response = await formaloo.updateCustomer({ - $, - customerId, - data: body, - }); - - $.export("$summary", `A new customer with Id: ${response?.data?.customer?.slug} was successfully created!`); - return response; - }, -}; diff --git a/components/formaloo/common/constants.mjs b/components/formaloo/common/constants.mjs new file mode 100644 index 0000000000000..89a70a381ef4a --- /dev/null +++ b/components/formaloo/common/constants.mjs @@ -0,0 +1,11 @@ +const BASE_URL = "https://api.formaloo.net"; +const VERSION_PATH = "/v2.0"; +const WEBHOOK_SLUG = "webhookSlug"; +const SECRET = "secret"; + +export default { + BASE_URL, + VERSION_PATH, + WEBHOOK_SLUG, + SECRET, +}; diff --git a/components/formaloo/formaloo.app.mjs b/components/formaloo/formaloo.app.mjs index 14fc7c07bea56..1789c5167a7d8 100644 --- a/components/formaloo/formaloo.app.mjs +++ b/components/formaloo/formaloo.app.mjs @@ -4,196 +4,28 @@ export default { type: "app", app: "formaloo", propDefinitions: { - city: { + formSlug: { type: "string", - label: "City", - description: "Customer's city slug", - async options({ - page, prevContext, stateSlug, - }) { - if (page && !prevContext.next) { - return []; - } - - const { data } = await this.listCities({ - params: { - state: stateSlug, - page: page + 1, - }, - }); - - return { - options: data?.cities.map(({ - slug: value, name: label, - }) => ({ - label, - value, - })), - context: { - next: data?.next, - }, - }; - }, - }, - countrySlug: { - type: "string", - label: "Country", - description: "Customer's country slug", - async options({ - page, prevContext, - }) { - if (page && !prevContext.next) { - return []; - } - const { data } = await this.listCountries({ - params: { - page: page + 1, - }, - }); - - return { - options: data?.countries.map(({ - slug: value, name: label, - }) => ({ - label, - value, - })), - context: { - next: data?.next, - }, - }; - }, - }, - customerId: { - type: "string", - label: "Customer Code", - description: "Customer's code", - async options({ - page, prevContext, - }) { - if (page && !prevContext.next) { - return []; - } - - const { data } = await this.listCustomers({ - params: { - page: page + 1, - }, - }); - - return { - options: data?.customers.map(({ - code: value, email: label, - }) => ({ - label, - value, - })), - context: { - next: data?.next, - }, - }; - }, - }, - customerData: { - type: "object", - label: "Customer Data", - description: "Any data available on the customer in json format.", - optional: true, - }, - email: { - type: "string", - label: "Email", - description: "Customer's primary email address.", - }, - firstName: { - type: "string", - label: "First Name", - description: "Customer's first name.", - }, - fullName: { - type: "string", - label: "Full Name", - description: "Customer's full name (in case it's not stored as the first name and last name).", - }, - lastName: { - type: "string", - label: "Last Name", - description: "Customer's last name.", - }, - language: { - type: "string", - label: "Language", - description: "Customer's language slug.", + label: "Form Slug", + description: "The slug of the form you want to add tags to.", async options({ page }) { - const { data } = await this.listLanguages({ + const { data: { forms } } = await this.listForms({ params: { - page, + page: page + 1, }, }); - - return data?.languages.map(({ + return forms.map(({ slug: value, title: label, }) => ({ - label, + label: label || value, value, })); }, }, - numberOfTags: { - type: "integer", - label: "Number Of Tags", - description: "The number of tags you want to add.", - }, - phoneNumber: { - type: "string", - label: "Phone Number", - description: "Customer's primary phone number.", - }, - score: { - type: "integer", - label: "Score", - description: "If you want the customer have an initial score.", - }, - stateSlug: { - type: "string", - label: "State", - description: "Customer's state slug", - async options({ - page, prevContext, countrySlug, - }) { - if (page && !prevContext.next) { - return []; - } - - const { data } = await this.listStates({ - countrySlug, - params: { - page: page + 1, - }, - }); - - return { - options: data?.states.map(({ - slug: value, name: label, - }) => ({ - label, - value, - })), - context: { - next: data?.next, - }, - }; - }, - }, - username: { - type: "string", - label: "Username", - description: "Any username or identifier on your system which you use to identify the customer.", - }, }, methods: { - _apiUrl() { - return "https://api.formaloo.net/v2.0"; + getUrl(path) { + return `https://api.formaloo.net/v2.0${path}`; }, _getHeaders() { return { @@ -201,96 +33,32 @@ export default { "x-api-key": `${this.$auth.api_key}`, }; }, - async _makeRequest({ + _makeRequest({ $ = this, path, ...opts }) { - const config = { - url: `${this._apiUrl()}/${path}/`, + return axios($, { + url: this.getUrl(path), headers: this._getHeaders(), ...opts, - }; - - return axios($, config); - }, - createCustomer(args = {}) { - return this._makeRequest({ - path: "customers", - method: "POST", - ...args, - }); - }, - listCities(args = {}) { - return this._makeRequest({ - path: "cities", - ...args, - }); - }, - listCountries(args = {}) { - return this._makeRequest({ - path: "countries", - ...args, - }); - }, - listCustomers(args = {}) { - return this._makeRequest({ - path: "customers", - ...args, - }); - }, - listLanguages(args = {}) { - return this._makeRequest({ - path: "languages", - ...args, }); }, - listStates({ - countrySlug, ...args - }) { + post(args = {}) { return this._makeRequest({ - path: `countries/${countrySlug}/states`, + method: "POST", ...args, }); }, - listTags(args = {}) { + delete(args = {}) { return this._makeRequest({ - path: "tags", + method: "DELETE", ...args, }); }, - updateCustomer({ - customerId, ...args - }) { + listForms(args = {}) { return this._makeRequest({ - path: `customers/${customerId}`, - method: "PUT", + path: "/forms/", ...args, }); }, - async *paginate({ - fn, params = {}, object, maxResults = null, - }) { - let hasNextPage = false; - let count = 0; - let page = 0; - - do { - params.page = ++page; - const { data } = await fn({ - params, - }); - const { next } = data; - - for (const d of data[object]) { - yield d; - - if (maxResults && ++count === maxResults) { - return count; - } - } - - hasNextPage = next; - - } while (hasNextPage); - }, }, }; diff --git a/components/formaloo/package.json b/components/formaloo/package.json index 42dc269261eb6..12e1f2bb7c313 100644 --- a/components/formaloo/package.json +++ b/components/formaloo/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/formaloo", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Formaloo Components", "main": "formaloo.app.mjs", "keywords": [ @@ -11,5 +11,9 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3", + "uuid": "^11.0.5" } } diff --git a/components/formaloo/sources/common/webhook.mjs b/components/formaloo/sources/common/webhook.mjs new file mode 100644 index 0000000000000..7378c6e7eadfd --- /dev/null +++ b/components/formaloo/sources/common/webhook.mjs @@ -0,0 +1,123 @@ +import { v4 as uuid } from "uuid"; +import { ConfigurationError } from "@pipedream/platform"; +import app from "../../formaloo.app.mjs"; +import constants from "../../common/constants.mjs"; + +export default { + props: { + app, + db: "$.service.db", + http: { + type: "$.interface.http", + customResponse: true, + }, + formSlug: { + propDefinition: [ + app, + "formSlug", + ], + }, + }, + hooks: { + async activate() { + const { + http: { endpoint: url }, + createWebhook, + formSlug, + setWebhookSlug, + setSecret, + getData, + } = this; + + const secret = uuid(); + const response = + await createWebhook({ + formSlug, + data: { + url, + secret, + active: true, + send_rendered_data: true, + send_raw_data: true, + ...getData(), + }, + }); + + setWebhookSlug(response?.data?.webhook?.slug); + setSecret(secret); + }, + async deactivate() { + const { + deleteWebhook, + formSlug, + getWebhookSlug, + } = this; + + const webhookSlug = getWebhookSlug(); + if (webhookSlug) { + await deleteWebhook({ + formSlug, + webhookSlug, + }); + } + }, + }, + methods: { + generateMeta() { + throw new ConfigurationError("generateMeta is not implemented"); + }, + setWebhookSlug(value) { + this.db.set(constants.WEBHOOK_SLUG, value); + }, + getWebhookSlug() { + return this.db.get(constants.WEBHOOK_SLUG); + }, + setSecret(value) { + this.db.set(constants.SECRET, value); + }, + getSecret() { + return this.db.get(constants.SECRET); + }, + getData() { + throw new ConfigurationError("getData is not implemented"); + }, + processResource(resource) { + this.$emit(resource, this.generateMeta(resource)); + }, + createWebhook({ + formSlug, ...args + } = {}) { + return this.app.post({ + debug: true, + path: `/forms/${formSlug}/webhooks/`, + ...args, + }); + }, + deleteWebhook({ + formSlug, webhookSlug, ...args + } = {}) { + return this.app.delete({ + debug: true, + path: `/forms/${formSlug}/webhooks/${webhookSlug}/`, + ...args, + }); + }, + }, + async run({ + body, headers, + }) { + const secret = this.getSecret(); + const token = headers["x-formaloo-token"]; + + if (token !== secret) { + throw new Error("Invalid token"); + } + + this.http.respond({ + status: 200, + body: "", + }); + + this.processResource(body); + }, +}; diff --git a/components/formaloo/sources/customer-created/customer-created.mjs b/components/formaloo/sources/customer-created/customer-created.mjs deleted file mode 100644 index cf93519ecb9e0..0000000000000 --- a/components/formaloo/sources/customer-created/customer-created.mjs +++ /dev/null @@ -1,77 +0,0 @@ -import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; -import moment from "moment"; -import formaloo from "../../formaloo.app.mjs"; - -export default { - key: "formaloo-customer-created", - name: "New Customer Created", - version: "0.0.1", - description: "Emit new event when a new customer is created.", - type: "source", - dedupe: "unique", - props: { - formaloo, - db: "$.service.db", - timer: { - label: "Polling interval", - description: "Pipedream will poll the Formaloo on this schedule", - type: "$.interface.timer", - default: { - intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, - }, - }, - }, - methods: { - _getLastDate() { - return this.db.get("lastDate"); - }, - _setLastDate(lastDate) { - this.db.set("lastDate", lastDate); - }, - async startEvent(maxResults) { - const lastDate = this._getLastDate() || moment("1970-01-01"); - let responseArray = []; - - const items = this.formaloo.paginate({ - object: "customers", - fn: this.formaloo.listCustomers, - maxResults, - }); - - let count = 0; - - for await (const item of items) { - responseArray.push(item); - - if (maxResults && ++count === maxResults) { - break; - } - } - - responseArray = responseArray.filter((item) => moment(item.created_at).isAfter(lastDate)); - - if (responseArray.length) { - this._setLastDate(responseArray[0].created_at); - } - - for (const responseItem of responseArray.reverse()) { - this.$emit( - responseItem, - { - id: responseItem.code, - summary: `A customer with code: "${responseItem.code}" was created!`, - ts: responseItem.created_at, - }, - ); - } - }, - }, - hooks: { - async deploy() { - await this.startEvent(25); - }, - }, - async run() { - await this.startEvent(); - }, -}; diff --git a/components/formaloo/sources/form-payment-completed-instant/form-payment-completed-instant.mjs b/components/formaloo/sources/form-payment-completed-instant/form-payment-completed-instant.mjs new file mode 100644 index 0000000000000..191bee7ee3ea3 --- /dev/null +++ b/components/formaloo/sources/form-payment-completed-instant/form-payment-completed-instant.mjs @@ -0,0 +1,26 @@ +import common from "../common/webhook.mjs"; + +export default { + ...common, + key: "formaloo-form-payment-completed-instant", + name: "Form Payment Completed (Instant)", + description: "Emit new event when a form payment is completed. [See the documentation](https://help.formaloo.com/en/articles/8568748-how-formaloo-webhook-works).", + type: "source", + version: "0.0.1", + dedupe: "unique", + methods: { + ...common.methods, + getData() { + return { + row_payment_events: true, + }; + }, + generateMeta(resource) { + return { + id: resource.event_id, + summary: `Form Payment Completed: ${resource.event_id}`, + ts: Date.parse(resource.created_at), + }; + }, + }, +}; diff --git a/components/formaloo/sources/form-payment-completed-instant/test-event.mjs b/components/formaloo/sources/form-payment-completed-instant/test-event.mjs new file mode 100644 index 0000000000000..d748602a8445b --- /dev/null +++ b/components/formaloo/sources/form-payment-completed-instant/test-event.mjs @@ -0,0 +1,115 @@ +export default { + "event_type": "row_payment", + "event_id": "xEJsGn", + "data": { + "field_QkcERTTt": "+1677673423", + "field_cfUkTmtq": "choice_kQqwcAXH", + "field_tClRSgaU": "Joh Doe" + }, + "rendered_data": [ + { + "slug": "field_tClRSgaU", + "type": "short_text", + "title": "Full Name", + "value": "Joh Doe", + "json_key": null, + "position": 1, + "raw_value": "Joh Doe", + "admin_only": false, + "json_value": null, + "max_length": 255 + }, + { + "slug": "field_QkcERTTt", + "type": "short_text", + "title": "Phone Number", + "value": "+1677673423", + "json_key": null, + "position": 2, + "max_value": null, + "min_value": null, + "raw_value": "+1677673423", + "admin_only": false, + "json_value": null + }, + { + "slug": "field_cfUkTmtq", + "type": "dropdown", + "title": "Select the food you want to buy", + "value": "Pizza", + "json_key": null, + "position": 3, + "raw_value": "choice_kQqwcAXH", + "admin_only": false, + "json_value": null, + "delta_score": { + "grade": 0.0, + "currency": 15.0 + }, + "choice_items": [ + { + "slug": "choice_zrKaPTwY", + "image": null, + "title": "Pasta", + "deleted": null, + "json_key": null, + "position": 1, + "created_at": "2021-07-25T11:14:07.806553+04:30", + "updated_at": "2021-07-25T11:14:07.861721+04:30" + }, + { + "slug": "choice_mTpKFfXl", + "image": null, + "title": "Burger", + "deleted": null, + "json_key": null, + "position": 2, + "created_at": "2021-07-25T11:14:07.806553+04:30", + "updated_at": "2021-07-25T11:14:07.861721+04:30" + }, + { + "slug": "choice_kQqwcAXH", + "image": null, + "title": "Pizza", + "deleted": null, + "json_key": null, + "position": 3, + "created_at": "2021-07-25T11:14:07.806553+04:30", + "updated_at": "2021-07-25T11:14:07.861721+04:30" + } + ] + }, + { + "slug": "order_status", + "title": "Order Status", + "value": "Successful", + "json_key": null, + "position": -1 + }, + { + "slug": "order_code", + "title": "Order Code", + "value": "4908799754916322", + "json_key": null, + "position": 1000 + }, + { + "slug": "payment_amount", + "title": "payment amount", + "value": 15.0, + "json_key": null, + "position": 999 + } + ], + "readable_data": { + "Full Name": "Joh Doe", + "Phone Number": "+1677673423", + "Order Status": "Successful", + "Order Code": "4908799754916322", + "payment amount": 15.0 + }, + "created_at": "2020-11-19T14:57:43.796281+01:00", + "updated_at": "2020-11-13T10:23:43.234323+01:00", + "submit_code": "UZF9XpVgY4sr5zmF", + "slug": "ZNtjCuScAjt349Rf" +}; diff --git a/components/formaloo/sources/form-submitted-instant/form-submitted-instant.mjs b/components/formaloo/sources/form-submitted-instant/form-submitted-instant.mjs new file mode 100644 index 0000000000000..1d074f7ad747c --- /dev/null +++ b/components/formaloo/sources/form-submitted-instant/form-submitted-instant.mjs @@ -0,0 +1,26 @@ +import common from "../common/webhook.mjs"; + +export default { + ...common, + key: "formaloo-form-submitted-instant", + name: "Form Submitted (Instant)", + description: "Emit new event when a form is submitted. [See the documentation](https://help.formaloo.com/en/articles/8568748-how-formaloo-webhook-works).", + type: "source", + version: "0.0.1", + dedupe: "unique", + methods: { + ...common.methods, + getData() { + return { + form_submit_events: true, + }; + }, + generateMeta(resource) { + return { + id: resource.event_id, + summary: `Form Submitted: ${resource.event_id}`, + ts: Date.parse(resource.created_at), + }; + }, + }, +}; diff --git a/components/formaloo/sources/form-submitted-instant/test-event.mjs b/components/formaloo/sources/form-submitted-instant/test-event.mjs new file mode 100644 index 0000000000000..ad27ce39741d3 --- /dev/null +++ b/components/formaloo/sources/form-submitted-instant/test-event.mjs @@ -0,0 +1,43 @@ +export default { + "event_type": "form_submit", + "event_id": "xEJsGn", + "data": { + "field_QkcERTTt": "+1677673423", + "field_tClRSgaU": "Joh Doe" + }, + "rendered_data": [ + { + "slug": "field_tClRSgaU", + "type": "short_text", + "title": "Full Name", + "value": "Joh Doe", + "json_key": null, + "position": 1, + "raw_value": "Joh Doe", + "admin_only": false, + "json_value": null, + "max_length": 255 + }, + { + "slug": "field_QkcERTTt", + "type": "short_text", + "title": "Phone Number", + "value": "+1677673423", + "json_key": null, + "position": 2, + "max_value": null, + "min_value": null, + "raw_value": "+1677673423", + "admin_only": false, + "json_value": null + } + ], + "readable_data": { + "Full Name": "Joh Doe", + "Phone Number": "+1677673423" + }, + "created_at": "2020-11-19T14:57:43.796281+01:00", + "updated_at": "2020-11-19T14:57:43.796281+01:00", + "submit_code": "UZF9XpVgY4sr5zmF", + "slug": "ZNtjCuScAjt349Rf" +}; diff --git a/components/formaloo/sources/row-updated-instant/row-updated-instant.mjs b/components/formaloo/sources/row-updated-instant/row-updated-instant.mjs new file mode 100644 index 0000000000000..8ec1e047ee01b --- /dev/null +++ b/components/formaloo/sources/row-updated-instant/row-updated-instant.mjs @@ -0,0 +1,26 @@ +import common from "../common/webhook.mjs"; + +export default { + ...common, + key: "formaloo-row-updated-instant", + name: "Row Updated (Instant)", + description: "Emit new event when a row is updated. [See the documentation](https://help.formaloo.com/en/articles/8568748-how-formaloo-webhook-works).", + type: "source", + version: "0.0.1", + dedupe: "unique", + methods: { + ...common.methods, + getData() { + return { + row_update_events: true, + }; + }, + generateMeta(resource) { + return { + id: resource.event_id, + summary: `Row Updated: ${resource.event_id}`, + ts: Date.parse(resource.created_at), + }; + }, + }, +}; diff --git a/components/formaloo/sources/row-updated-instant/test-event.mjs b/components/formaloo/sources/row-updated-instant/test-event.mjs new file mode 100644 index 0000000000000..2973905a8bde8 --- /dev/null +++ b/components/formaloo/sources/row-updated-instant/test-event.mjs @@ -0,0 +1,43 @@ +export default { + "event_type": "row_update", + "event_id": "xEJsGn", + "data": { + "field_QkcERTTt": "+1677673423", + "field_tClRSgaU": "Joh Doe" + }, + "rendered_data": [ + { + "slug": "field_tClRSgaU", + "type": "short_text", + "title": "Full Name", + "value": "Joh Doe", + "json_key": null, + "position": 1, + "raw_value": "Joh Doe", + "admin_only": false, + "json_value": null, + "max_length": 255 + }, + { + "slug": "field_QkcERTTt", + "type": "short_text", + "title": "Phone Number", + "value": "+1677673423", + "json_key": null, + "position": 2, + "max_value": null, + "min_value": null, + "raw_value": "+1677673423", + "admin_only": false, + "json_value": null + } + ], + "readable_data": { + "Full Name": "Joh Doe", + "Phone Number": "+1677673423" + }, + "created_at": "2020-11-19T14:57:43.796281+01:00", + "updated_at": "2020-11-13T10:23:43.234323+01:00", + "submit_code": "UZF9XpVgY4sr5zmF", + "slug": "ZNtjCuScAjt349Rf" +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index beac226947129..1f3f000d14205 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3843,7 +3843,14 @@ importers: components/form_io: {} - components/formaloo: {} + components/formaloo: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 + uuid: + specifier: ^11.0.5 + version: 11.0.5 components/formatting: dependencies: @@ -32267,8 +32274,6 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) - transitivePeerDependencies: - - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: