From d4ae7a09a34e99a0b7fd2afeba7572adc3928ce0 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 21 May 2025 13:44:25 -0400 Subject: [PATCH 1/4] new components --- .../actions/search-leads/search-leads.mjs | 29 ++++++++++++ components/nextlead/nextlead.app.mjs | 45 +++++++++++++++++-- components/nextlead/package.json | 7 ++- components/nextlead/sources/common/base.mjs | 14 ++++++ .../new-lead-added-to-list.mjs | 29 ++++++++++++ .../new-lead-added-to-list/test-event.mjs | 16 +++++++ .../new-lead-created/new-lead-created.mjs | 29 ++++++++++++ .../sources/new-lead-created/test-event.mjs | 19 ++++++++ .../new-lead-updated/new-lead-updated.mjs | 29 ++++++++++++ .../sources/new-lead-updated/test-event.mjs | 19 ++++++++ 10 files changed, 230 insertions(+), 6 deletions(-) create mode 100644 components/nextlead/actions/search-leads/search-leads.mjs create mode 100644 components/nextlead/sources/common/base.mjs create mode 100644 components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs create mode 100644 components/nextlead/sources/new-lead-added-to-list/test-event.mjs create mode 100644 components/nextlead/sources/new-lead-created/new-lead-created.mjs create mode 100644 components/nextlead/sources/new-lead-created/test-event.mjs create mode 100644 components/nextlead/sources/new-lead-updated/new-lead-updated.mjs create mode 100644 components/nextlead/sources/new-lead-updated/test-event.mjs diff --git a/components/nextlead/actions/search-leads/search-leads.mjs b/components/nextlead/actions/search-leads/search-leads.mjs new file mode 100644 index 0000000000000..362a91851487b --- /dev/null +++ b/components/nextlead/actions/search-leads/search-leads.mjs @@ -0,0 +1,29 @@ +import nextlead from "../../nextlead.app.mjs"; + +export default { + key: "nextlead-search-leads", + name: "Search Leads", + description: "Search for leads by email in NextLead. [See the documentation](https://dashboard.nextlead.app/en/api-documentation#find)", + version: "0.0.1", + type: "action", + props: { + nextlead, + email: { + type: "string", + label: "Email", + description: "The email address to search for", + }, + }, + async run({ $ }) { + const response = await this.nextlead.searchLeads({ + $, + data: { + email: this.email, + }, + }); + $.export("$summary", `Found ${response.length && response[0].found + ? response.length + : 0} lead(s) for email: ${this.email}`); + return response; + }, +}; diff --git a/components/nextlead/nextlead.app.mjs b/components/nextlead/nextlead.app.mjs index 2a417f9769ce1..0f0e033a66299 100644 --- a/components/nextlead/nextlead.app.mjs +++ b/components/nextlead/nextlead.app.mjs @@ -1,11 +1,48 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "nextlead", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return this.$auth.api_url; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: `${this._baseUrl()}${path}`, + headers: { + Authorization: `Bearer ${this.$auth.api_key}`, + }, + ...opts, + }); + }, + searchLeads(opts = {}) { + return this._makeRequest({ + path: "/receive/contact/find-contact", + method: "POST", + ...opts, + }); + }, + getNewlyCreatedLeads(opts = {}) { + return this._makeRequest({ + path: "/polling/contact/user-created", + ...opts, + }); + }, + getNewlyUpdatedLeads(opts = {}) { + return this._makeRequest({ + path: "/polling/contact/user-edited", + ...opts, + }); + }, + getContactsAddedToList(opts = {}) { + return this._makeRequest({ + path: "/polling/email/added-to-list", + ...opts, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/nextlead/package.json b/components/nextlead/package.json index 2e7e231641bc7..a5adc6c486868 100644 --- a/components/nextlead/package.json +++ b/components/nextlead/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/nextlead", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Nextlead Components", "main": "nextlead.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/nextlead/sources/common/base.mjs b/components/nextlead/sources/common/base.mjs new file mode 100644 index 0000000000000..e09ae7d0d1519 --- /dev/null +++ b/components/nextlead/sources/common/base.mjs @@ -0,0 +1,14 @@ +import nextlead from "../../nextlead.app.mjs"; +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; + +export default { + props: { + nextlead, + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, +}; diff --git a/components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs b/components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs new file mode 100644 index 0000000000000..67a939d808389 --- /dev/null +++ b/components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs @@ -0,0 +1,29 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "nextlead-new-lead-added-to-list", + name: "New Lead Added to List", + description: "Emit new event when a lead is added to a list in NextLead. [See the documentation](https://dashboard.nextlead.app/en/api-documentation#addedToList)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + generateMeta(lead) { + return { + id: lead.id, + summary: "Lead Added to List", + ts: Date.parse(lead.created_at), + }; + }, + }, + async run() { + const leads = await this.nextlead.getContactsAddedToList(); + for (const lead of leads) { + const meta = this.generateMeta(lead); + this.$emit(lead, meta); + } + }, + sampleEmit, +}; diff --git a/components/nextlead/sources/new-lead-added-to-list/test-event.mjs b/components/nextlead/sources/new-lead-added-to-list/test-event.mjs new file mode 100644 index 0000000000000..d0808f56db680 --- /dev/null +++ b/components/nextlead/sources/new-lead-added-to-list/test-event.mjs @@ -0,0 +1,16 @@ +export default { + "id": "cmay8b4jx0001ky04yb204e5b", + "result": { + "created_at": "2025-05-21T17:40:39.501Z", + "organization_id": "cmay3tgaa0002jr04l5tga7my", + "email": null, + "first_name": "Jane", + "last_name": "Doe", + "phone": null, + "address": null, + "civility": "NEUTRAL", + "status": null, + "opt_in_marketing": true, + "opt_in_newsletter": true + } + } \ No newline at end of file diff --git a/components/nextlead/sources/new-lead-created/new-lead-created.mjs b/components/nextlead/sources/new-lead-created/new-lead-created.mjs new file mode 100644 index 0000000000000..ed41c871e11e0 --- /dev/null +++ b/components/nextlead/sources/new-lead-created/new-lead-created.mjs @@ -0,0 +1,29 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "nextlead-new-lead-created", + name: "New Lead Created", + description: "Emit new event when a new lead is captured in NextLead. [See the documentation](https://dashboard.nextlead.app/en/api-documentation#created)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + generateMeta(lead) { + return { + id: lead.id, + summary: "New Lead Created", + ts: Date.parse(lead.created_at), + }; + }, + }, + async run() { + const leads = await this.nextlead.getNewlyCreatedLeads(); + for (const lead of leads) { + const meta = this.generateMeta(lead); + this.$emit(lead, meta); + } + }, + sampleEmit, +}; diff --git a/components/nextlead/sources/new-lead-created/test-event.mjs b/components/nextlead/sources/new-lead-created/test-event.mjs new file mode 100644 index 0000000000000..bcf7e15310414 --- /dev/null +++ b/components/nextlead/sources/new-lead-created/test-event.mjs @@ -0,0 +1,19 @@ +export default { + "id": "cmay7x5ou0001k10442mgpngp", + "type": "CLIENT", + "civility": "NEUTRAL", + "first_name": null, + "last_name": null, + "birth_date": null, + "sector": null, + "activity": null, + "status": null, + "conversion_status": null, + "lead_score": null, + "phone": null, + "mobile": null, + "phone_pro": null, + "email": null, + "email2": null, + "email_verified": null + } \ No newline at end of file diff --git a/components/nextlead/sources/new-lead-updated/new-lead-updated.mjs b/components/nextlead/sources/new-lead-updated/new-lead-updated.mjs new file mode 100644 index 0000000000000..063d1b0c8dcee --- /dev/null +++ b/components/nextlead/sources/new-lead-updated/new-lead-updated.mjs @@ -0,0 +1,29 @@ +import common from "../common/base.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "nextlead-new-lead-updated", + name: "New Lead Updated", + description: "Emit new event when a lead is updated in NextLead. [See the documentation](https://dashboard.nextlead.app/en/api-documentation#edited)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + generateMeta(lead) { + return { + id: lead.id, + summary: "Lead Updated", + ts: Date.parse(lead.updated_at), + }; + }, + }, + async run() { + const leads = await this.nextlead.getNewlyUpdatedLeads(); + for (const lead of leads) { + const meta = this.generateMeta(lead); + this.$emit(lead, meta); + } + }, + sampleEmit, +}; diff --git a/components/nextlead/sources/new-lead-updated/test-event.mjs b/components/nextlead/sources/new-lead-updated/test-event.mjs new file mode 100644 index 0000000000000..eb505e2641f41 --- /dev/null +++ b/components/nextlead/sources/new-lead-updated/test-event.mjs @@ -0,0 +1,19 @@ +export default { + "id": "cmay7zwqw000fib046wynimr1", + "type": "CLIENT", + "civility": "NEUTRAL", + "first_name": "Jane", + "last_name": "Doe", + "birth_date": null, + "sector": null, + "activity": null, + "status": null, + "conversion_status": null, + "lead_score": null, + "phone": null, + "mobile": null, + "phone_pro": null, + "email": null, + "email2": null, + "email_verified": null + } \ No newline at end of file From ed0deefe5a2b049468b1a3c934d443074f811c15 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 21 May 2025 13:45:03 -0400 Subject: [PATCH 2/4] pnpm-lock.yaml --- pnpm-lock.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c9e553c9617cf..a56e229e6453e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8564,8 +8564,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/neetoform: - specifiers: {} + components/neetoform: {} components/neetoinvoice: dependencies: @@ -8694,7 +8693,11 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/nextlead: {} + components/nextlead: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/nexudus: {} @@ -35830,6 +35833,8 @@ 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: From 4af550ef122dca268ee3bcd1866006093ae4a2fd Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Wed, 21 May 2025 13:58:29 -0400 Subject: [PATCH 3/4] updates --- .../sources/new-lead-added-to-list/new-lead-added-to-list.mjs | 2 +- .../nextlead/sources/new-lead-created/new-lead-created.mjs | 2 +- .../nextlead/sources/new-lead-updated/new-lead-updated.mjs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs b/components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs index 67a939d808389..fbbc3d0cbf565 100644 --- a/components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs +++ b/components/nextlead/sources/new-lead-added-to-list/new-lead-added-to-list.mjs @@ -14,7 +14,7 @@ export default { return { id: lead.id, summary: "Lead Added to List", - ts: Date.parse(lead.created_at), + ts: Date.parse(lead.result.created_at), }; }, }, diff --git a/components/nextlead/sources/new-lead-created/new-lead-created.mjs b/components/nextlead/sources/new-lead-created/new-lead-created.mjs index ed41c871e11e0..23189d1f38225 100644 --- a/components/nextlead/sources/new-lead-created/new-lead-created.mjs +++ b/components/nextlead/sources/new-lead-created/new-lead-created.mjs @@ -14,7 +14,7 @@ export default { return { id: lead.id, summary: "New Lead Created", - ts: Date.parse(lead.created_at), + ts: Date.now(), }; }, }, diff --git a/components/nextlead/sources/new-lead-updated/new-lead-updated.mjs b/components/nextlead/sources/new-lead-updated/new-lead-updated.mjs index 063d1b0c8dcee..3ecf75bf48ae6 100644 --- a/components/nextlead/sources/new-lead-updated/new-lead-updated.mjs +++ b/components/nextlead/sources/new-lead-updated/new-lead-updated.mjs @@ -14,7 +14,7 @@ export default { return { id: lead.id, summary: "Lead Updated", - ts: Date.parse(lead.updated_at), + ts: Date.now(), }; }, }, From d6805c651ea8aff5bc57b2879b9e5be6558ac470 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 26 May 2025 11:45:54 -0400 Subject: [PATCH 4/4] pnpm-lock.yaml --- pnpm-lock.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9f515a1d9ba63..04842669c8cd6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5445,8 +5445,7 @@ importers: specifier: ^8.3.2 version: 8.3.2 - components/google_cloud_document_ai: - specifiers: {} + components/google_cloud_document_ai: {} components/google_cloud_translate: {} @@ -13234,11 +13233,9 @@ importers: components/test_apps_for_checking_something_006: {} - components/test_apps_for_checking_something_009: - specifiers: {} + components/test_apps_for_checking_something_009: {} - components/test_apps_for_checking_something_010: - specifiers: {} + components/test_apps_for_checking_something_010: {} components/test_apps_for_switching_appslug_009: {}